[PATCH v8 3/3] PCI: Add a macro to set default alignment for all PCI devices

2017-01-19 Thread Yongji Xie
When vfio passthroughs a PCI device of which MMIO BARs are smaller than PAGE_SIZE, guest will not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because vfio will not allow to passthrough one BAR's mmio page which may be shared with other BARs. Otherwise, ther

[PATCH v8 2/3] PCI: Make sure the driver could get correct BAR size from pci_resource_len()

2017-01-19 Thread Yongji Xie
When using resource_alignment kernel parameter, the current implement reassigns the alignment by expanding resources' size. So there exists two kinds of *size* for one PCI BAR. One is the hardware size, the other is the allocated size. Currently pci_resource_len() used by drivers return the allocat

[PATCH v8 1/3] PCI: Ignore requested alignment for IOV BARs

2017-01-19 Thread Yongji Xie
We would call pci_reassigndev_resource_alignment() before pci_init_capabilities(). So the requested alignment would never work for IOV BARs. Furthermore, it's meaningless to request additional alignment for IOV BARs, the IOV BAR alignment is only determined by the VF BAR size. Signed-off-by: Yong

[PATCH v8 0/3] PCI: Introduce a way to enforce all MMIO BARs not to share PAGE_SIZE

2017-01-19 Thread Yongji Xie
This series introduces a way for PCI resource allocator to force MMIO BARs not to share PAGE_SIZE. This would make sense to VFIO driver. Because current VFIO implementation disallows to mmap sub-page(size < PAGE_SIZE) MMIO BARs which may share the same page with other BARs for security reasons. Thu

Re: powerpc/nvram: Move an assignment for the variable "ret" in dev_nvram_write()

2017-01-19 Thread SF Markus Elfring
> I think you really could have squashed patches 1-3 into a single patch > that returns directly after any failure. Thanks for your constructive feedback. I have got software development concerns around such patch squashing. > At this point you might as well remove that label and move the kfree

Re: [PATCH v4 2/5] ia64: reuse append_elf_note() and final_note() functions

2017-01-19 Thread Michael Ellerman
Hari Bathini writes: > Get rid of multiple definitions of append_elf_note() & final_note() > functions. Reuse these functions compiled under CONFIG_CRASH_CORE > Also, define Elf_Word and use it instead of generic u32 or the more > specific Elf64_Word. > > Signed-off-by: Hari Bathini > --- > > Ch

Re: [PATCH 3/8] powerpc/nvram: Move an assignment for the variable "ret" in dev_nvram_write()

2017-01-19 Thread Tyrel Datwyler
On 01/19/2017 08:56 AM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Thu, 19 Jan 2017 15:55:36 +0100 > > A local variable was set to an error code before a concrete error situation > was detected. Thus move the corresponding assignment into an if branch > to indicate a software failure

Re: [PATCH] powerpc/rtas_flash: Move an assignment for the variable "rc" in manage_flash_write()

2017-01-19 Thread Tyrel Datwyler
On 01/19/2017 12:33 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Thu, 19 Jan 2017 21:20:09 +0100 > > A local variable was set to an error code before a concrete error situation > was detected. Thus move the corresponding assignment into an if branch > to indicate a software failure

[PATCH] powerpc/rtas_flash: Move an assignment for the variable "rc" in manage_flash_write()

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 21:20:09 +0100 A local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding assignment into an if branch to indicate a software failure there. This issue was detected by using the Coccinelle soft

Re: [PATCH v4 3/3] modversions: treat symbol CRCs as 32 bit quantities on 64 bit archs

2017-01-19 Thread Linus Torvalds
On Thu, Jan 19, 2017 at 1:22 AM, Ard Biesheuvel wrote: >> >> Your genksyms.c change is not exactly obvious. I looked at it, and my >> brain just shut down. Why both the >> >> LONG(0x%08lx); >> >> _and_ the >> >> "%s__crc_%s = 0x%08lx;\n" >> >> in the linker script? I'm sure there's a good reas

[PATCH 1/8] powerpc/nvram: Return directly after a failed parameter validation in dev_nvram_write()

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 15:22:56 +0100 * Return directly after an inappropriate input parameter was detected. * Delete an initialisation for the variable "tmp" at the beginning and an assignment for the variable "ret" which became unnecessary with this refactoring. Signe

[PATCH 5/8] powerpc/nvram: Return directly after a failed kmalloc() in dev_nvram_read()

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 16:50:31 +0100 Return directly after a call of the function "kmalloc" failed here. Signed-off-by: Markus Elfring --- arch/powerpc/kernel/nvram_64.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/nvram_64

[PATCH 8/8] powerpc/nvram: Move an assignment for the variable "err" in nvram_scan_partitions()

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 17:27:37 +0100 A local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding assignment into an if branch to indicate a software failure there. Signed-off-by: Markus Elfring --- arch/powerpc/ker

[PATCH 7/8] powerpc/nvram: Improve size determinations in three functions

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 17:15:30 +0100 Replace the specification of data structures by references for local variables as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer. Signed-off-by: Markus Elfring --- arch/powerpc/kernel/n

[PATCH 3/8] powerpc/nvram: Move an assignment for the variable "ret" in dev_nvram_write()

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 15:55:36 +0100 A local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding assignment into an if branch to indicate a software failure there. This issue was detected by using the Coccinelle soft

[PATCH 4/8] powerpc/nvram: Return directly after a failed parameter validation in dev_nvram_read()

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 16:12:48 +0100 * Return directly after an inappropriate input parameter was detected. * Delete an initialisation for the variable "tmp" at the beginning which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- arch/powerpc

[PATCH 2/8] powerpc/nvram: Return directly after a failed kmalloc() in dev_nvram_write()

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 15:44:03 +0100 Return directly after a call of the function "kmalloc" failed here. Signed-off-by: Markus Elfring --- arch/powerpc/kernel/nvram_64.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/nvram_64.c

[PATCH 6/8] powerpc/nvram: Delete three error messages for a failed memory allocation

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 16:56:46 +0100 The script "checkpatch.pl" pointed information out like the following. WARNING: Possible unnecessary 'out of memory' message Thus fix affected source code places. Signed-off-by: Markus Elfring --- arch/powerpc/kernel/nvram_64.c | 12

RE: [PATCH v4 3/3] modversions: treat symbol CRCs as 32 bit quantities on 64 bit archs

2017-01-19 Thread David Laight
From: Ard Biesheuvel > Sent: 18 January 2017 13:53 .. > It turns out that this odd treatment of absolute symbols (i.e., > symbols having section number SHN_ABS) is a known issue in GNU ld > > https://sourceware.org/ml/binutils/2012-05/msg00019.html ... Jeepers - that is truly f*cked. I've even

Re: [RFC PATCH v2] modversions: redefine kcrctab entries as relative CRC pointers

2017-01-19 Thread Ard Biesheuvel
On 19 January 2017 at 16:55, Ard Biesheuvel wrote: > On 19 January 2017 at 12:02, Ard Biesheuvel wrote: >> The modversion symbol CRCs are emitted as ELF symbols, which allows us to >> easily populate the kcrctab sections by relying on the linker to associate >> each kcrctab slot with the correct

[PATCH 0/8] PowerPC-NVRAM: Fine-tuning for some function implementations

2017-01-19 Thread SF Markus Elfring
From: Markus Elfring Date: Thu, 19 Jan 2017 17:41:23 +0100 Some update suggestions were taken into account from static source code analysis. Markus Elfring (8): Return directly after a failed parameter validation in dev_nvram_write() Return directly after a failed kmalloc() in dev_nvram_writ

Re: [RFC PATCH v2] modversions: redefine kcrctab entries as relative CRC pointers

2017-01-19 Thread Ard Biesheuvel
On 19 January 2017 at 12:02, Ard Biesheuvel wrote: > The modversion symbol CRCs are emitted as ELF symbols, which allows us to > easily populate the kcrctab sections by relying on the linker to associate > each kcrctab slot with the correct value. > > This has a couple of downsides: > - On archite

[PATCH v4 15/15] livepatch: allow removal of a disabled patch

2017-01-19 Thread Josh Poimboeuf
From: Miroslav Benes Currently we do not allow patch module to unload since there is no method to determine if a task is still running in the patched code. The consistency model gives us the way because when the unpatching finishes we know that all tasks were marked as safe to call an original f

[PATCH v4 14/15] livepatch: add /proc//patch_state

2017-01-19 Thread Josh Poimboeuf
Expose the per-task patch state value so users can determine which tasks are holding up completion of a patching operation. Signed-off-by: Josh Poimboeuf Reviewed-by: Petr Mladek Reviewed-by: Miroslav Benes --- Documentation/filesystems/proc.txt | 18 ++ fs/proc/base.c

[PATCH v4 13/15] livepatch: change to a per-task consistency model

2017-01-19 Thread Josh Poimboeuf
Change livepatch to use a basic per-task consistency model. This is the foundation which will eventually enable us to patch those ~10% of security patches which change function or data semantics. This is the biggest remaining piece needed to make livepatch more generally useful. This code stems

[PATCH v4 12/15] livepatch: store function sizes

2017-01-19 Thread Josh Poimboeuf
For the consistency model we'll need to know the sizes of the old and new functions to determine if they're on the stacks of any tasks. Signed-off-by: Josh Poimboeuf Acked-by: Miroslav Benes Reviewed-by: Petr Mladek Reviewed-by: Kamalesh Babulal --- include/linux/livepatch.h | 3 +++ kernel/

[PATCH v4 11/15] livepatch: use kstrtobool() in enabled_store()

2017-01-19 Thread Josh Poimboeuf
The sysfs enabled value is a boolean, so kstrtobool() is a better fit for parsing the input string since it does the range checking for us. Suggested-by: Petr Mladek Signed-off-by: Josh Poimboeuf Acked-by: Miroslav Benes Reviewed-by: Petr Mladek --- kernel/livepatch/core.c | 13 +

[PATCH v4 10/15] livepatch: move patching functions into patch.c

2017-01-19 Thread Josh Poimboeuf
Move functions related to the actual patching of functions and objects into a new patch.c file. Signed-off-by: Josh Poimboeuf Acked-by: Miroslav Benes Reviewed-by: Petr Mladek Reviewed-by: Kamalesh Babulal --- kernel/livepatch/Makefile | 2 +- kernel/livepatch/core.c | 202 +--

[PATCH v4 09/15] livepatch: remove unnecessary object loaded check

2017-01-19 Thread Josh Poimboeuf
klp_patch_object()'s callers already ensure that the object is loaded, so its call to klp_is_object_loaded() is unnecessary. This will also make it possible to move the patching code into a separate file. Signed-off-by: Josh Poimboeuf Acked-by: Miroslav Benes Reviewed-by: Petr Mladek Reviewed-

[PATCH v4 08/15] livepatch: separate enabled and patched states

2017-01-19 Thread Josh Poimboeuf
Once we have a consistency model, patches and their objects will be enabled and disabled at different times. For example, when a patch is disabled, its loaded objects' funcs can remain registered with ftrace indefinitely until the unpatching operation is complete and they're no longer in use. It'

[PATCH v4 07/15] livepatch/s390: add TIF_PATCH_PENDING thread flag

2017-01-19 Thread Josh Poimboeuf
From: Miroslav Benes Update a task's patch state when returning from a system call or user space interrupt, or after handling a signal. This greatly increases the chances of a patch operation succeeding. If a task is I/O bound, it can be patched when returning from a system call. If a task is

[PATCH v4 06/15] livepatch/s390: reorganize TIF thread flag bits

2017-01-19 Thread Josh Poimboeuf
From: Jiri Slaby Group the TIF thread flag bits by their inclusion in the _TIF_WORK and _TIF_TRACE macros. Signed-off-by: Jiri Slaby Signed-off-by: Josh Poimboeuf Reviewed-by: Miroslav Benes --- arch/s390/include/asm/thread_info.h | 22 ++ 1 file changed, 14 insertions(+)

[PATCH v4 05/15] livepatch/powerpc: add TIF_PATCH_PENDING thread flag

2017-01-19 Thread Josh Poimboeuf
Add the TIF_PATCH_PENDING thread flag to enable the new livepatch per-task consistency model for powerpc. The bit getting set indicates the thread has a pending patch which needs to be applied when the thread exits the kernel. The bit is included in the _TIF_USER_WORK_MASK macro so that do_notify

[PATCH v4 04/15] livepatch/x86: add TIF_PATCH_PENDING thread flag

2017-01-19 Thread Josh Poimboeuf
Add the TIF_PATCH_PENDING thread flag to enable the new livepatch per-task consistency model for x86_64. The bit getting set indicates the thread has a pending patch which needs to be applied when the thread exits the kernel. The bit is placed in the _TIF_ALLWORK_MASK macro, which results in exit

[PATCH v4 03/15] livepatch: create temporary klp_update_patch_state() stub

2017-01-19 Thread Josh Poimboeuf
Create temporary stubs for klp_update_patch_state() so we can add TIF_PATCH_PENDING to different architectures in separate patches without breaking build bisectability. Signed-off-by: Josh Poimboeuf Reviewed-by: Petr Mladek --- include/linux/livepatch.h | 5 - kernel/livepatch/core.c | 3

[PATCH v4 02/15] x86/entry: define _TIF_ALLWORK_MASK flags explicitly

2017-01-19 Thread Josh Poimboeuf
The _TIF_ALLWORK_MASK macro automatically includes the least-significant 16 bits of the thread_info flags, which is less than obvious and tends to create confusion and surprises when reading or modifying the code. Define the flags explicitly. Signed-off-by: Josh Poimboeuf Reviewed-by: Petr Mlade

[PATCH v4 01/15] stacktrace/x86: add function for detecting reliable stack traces

2017-01-19 Thread Josh Poimboeuf
For live patching and possibly other use cases, a stack trace is only useful if it can be assured that it's completely reliable. Add a new save_stack_trace_tsk_reliable() function to achieve that. Note that if the target task isn't the current task, and the target task is allowed to run, then it

[PATCH v4 00/15] livepatch: hybrid consistency model

2017-01-19 Thread Josh Poimboeuf
Here's v4, based on linux-next/master. Mostly minor changes this time, primarily due to Petr's v3 comments. v4: - add warnings for "impossible" scenarios in __save_stack_trace_reliable() - sort _TIF_ALLWORK_MASK flags - move klp_transition_work to transition.c. This resulted in the following

Re: [PATCH] cxl: drop unused header asm/pnv-pci.h

2017-01-19 Thread Andrew Donnellan
On 19/01/17 21:50, Greg Kurz wrote: The kernel API does not use anything from this header file. Signed-off-by: Greg Kurz Reviewed-by: Andrew Donnellan -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnel...@au1.ibm.com IBM Australia Limited

[RFC PATCH v2] modversions: redefine kcrctab entries as relative CRC pointers

2017-01-19 Thread Ard Biesheuvel
The modversion symbol CRCs are emitted as ELF symbols, which allows us to easily populate the kcrctab sections by relying on the linker to associate each kcrctab slot with the correct value. This has a couple of downsides: - On architectures that support runtime relocation, a R__RELATIVE relocat

[PATCH] cxl: drop unused header asm/pnv-pci.h

2017-01-19 Thread Greg Kurz
The kernel API does not use anything from this header file. Signed-off-by: Greg Kurz --- drivers/misc/cxl/api.c |1 - 1 file changed, 1 deletion(-) diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c index 1b35e33d2434..bcc030eacab7 100644 --- a/drivers/misc/cxl/api.c +++ b/drivers

Re: [PATCH 2/2] of: Add function for generating a DT modalias with a newline

2017-01-19 Thread Greg Kroah-Hartman
On Mon, Jan 16, 2017 at 02:41:22PM -0600, Rob Herring wrote: > The modalias sysfs attr is lacking a newline for DT aliases on platform > devices. The macio and ibmebus correctly add the newline, but open code it. > Introduce a new function, of_device_modalias(), that fills the buffer with > the mod

Re: [PATCH v4 3/3] modversions: treat symbol CRCs as 32 bit quantities on 64 bit archs

2017-01-19 Thread Ard Biesheuvel
On 19 January 2017 at 00:15, Linus Torvalds wrote: > On Wed, Jan 18, 2017 at 2:37 PM, Ard Biesheuvel > wrote: >> >> For a ballpark number of 10,000 CRCs in the core kernel, this would >> increase the size of the image by 40 KB for 32-bit architectures (and >> if saving 40 KB is essential, chances