[PATCH v3 15/16] Documentation/powerpc: Ultravisor API

2019-08-05 Thread Thiago Jung Bauermann
From: Sukadev Bhattiprolu POWER9 processor includes support for Protected Execution Facility (PEF). Attached documentation provides an overview of PEF and defines the API for various interfaces that must be implemented in the Ultravisor firmware as well as in the KVM Hypervisor. Based on input

Re: [PATCH 4/7] ALSA: pcm: use dma_can_mmap() to check if a device supports dma_mmap_*

2019-08-05 Thread Christoph Hellwig
On Mon, Aug 05, 2019 at 11:22:03AM +0200, Takashi Iwai wrote: > This won't work as expected, unfortunately. It's a bit tricky check, > since the driver may have its own mmap implementation via > substream->ops->mmap, and the dma_buffer.dev.dev might point to > another object depending on the

[PATCH v3 14/16] powerpc/pseries/svm: Force SWIOTLB for secure guests

2019-08-05 Thread Thiago Jung Bauermann
From: Anshuman Khandual SWIOTLB checks range of incoming CPU addresses to be bounced and sees if the device can access it through its DMA window without requiring bouncing. In such cases it just chooses to skip bouncing. But for cases like secure guests on powerpc platform all addresses need to

[PATCH v3 13/16] powerpc/pseries/iommu: Don't use dma_iommu_ops on secure guests

2019-08-05 Thread Thiago Jung Bauermann
Secure guest memory is inacessible to devices so regular DMA isn't possible. In that case set devices' dma_map_ops to NULL so that the generic DMA code path will use SWIOTLB and DMA to bounce buffers. Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/platforms/pseries/iommu.c | 6 +- 1

[PATCH v3 12/16] powerpc/pseries/svm: Disable doorbells in SVM guests

2019-08-05 Thread Thiago Jung Bauermann
From: Sukadev Bhattiprolu Normally, the HV emulates some instructions like MSGSNDP, MSGCLRP from a KVM guest. To emulate the instructions, it must first read the instruction from the guest's memory and decode its parameters. However for a secure guest (aka SVM), the page containing the

[PATCH v3 11/16] powerpc/pseries/svm: Export guest SVM status to user space via sysfs

2019-08-05 Thread Thiago Jung Bauermann
From: Ryan Grimm User space might want to know it's running in a secure VM. It can't do a mfmsr because mfmsr is a privileged instruction. The solution here is to create a cpu attribute: /sys/devices/system/cpu/svm which will read 0 or 1 based on the S bit of the guest's CPU 0.

[PATCH v3 10/16] powerpc/pseries/svm: Unshare all pages before kexecing a new kernel

2019-08-05 Thread Thiago Jung Bauermann
From: Ram Pai A new kernel deserves a clean slate. Any pages shared with the hypervisor is unshared before invoking the new kernel. However there are exceptions. If the new kernel is invoked to dump the current kernel, or if there is a explicit request to preserve the state of the current

[PATCH v3 09/16] powerpc/pseries/svm: Use shared memory for Debug Trace Log (DTL)

2019-08-05 Thread Thiago Jung Bauermann
From: Anshuman Khandual Secure guests need to share the DTL buffers with the hypervisor. To that end, use a kmem_cache constructor which converts the underlying buddy allocated SLUB cache pages into shared memory. Signed-off-by: Anshuman Khandual Signed-off-by: Thiago Jung Bauermann ---

[PATCH v3 08/16] powerpc/pseries/svm: Use shared memory for LPPACA structures

2019-08-05 Thread Thiago Jung Bauermann
From: Anshuman Khandual LPPACA structures need to be shared with the host. Hence they need to be in shared memory. Instead of allocating individual chunks of memory for a given structure from memblock, a contiguous chunk of memory is allocated and then converted into shared memory. Subsequent

[PATCH v3 07/16] powerpc/pseries: Add and use LPPACA_SIZE constant

2019-08-05 Thread Thiago Jung Bauermann
Helps document what the hard-coded number means. Also take the opportunity to fix an #endif comment. Suggested-by: Alexey Kardashevskiy Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/kernel/paca.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git

[PATCH v3 06/16] powerpc: Introduce the MSR_S bit

2019-08-05 Thread Thiago Jung Bauermann
From: Sukadev Bhattiprolu The ultravisor processor mode is introduced in POWER platforms that supports the Protected Execution Facility (PEF). Ultravisor is higher privileged than hypervisor mode. In PEF enabled platforms, the MSR_S bit is used to indicate if the thread is in secure state. With

[PATCH v3 05/16] powerpc/pseries/svm: Add helpers for UV_SHARE_PAGE and UV_UNSHARE_PAGE

2019-08-05 Thread Thiago Jung Bauermann
From: Ram Pai These functions are used when the guest wants to grant the hypervisor access to certain pages. Signed-off-by: Ram Pai Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/ultravisor-api.h | 2 ++ arch/powerpc/include/asm/ultravisor.h | 24

[PATCH v3 04/16] powerpc/prom_init: Add the ESM call to prom_init

2019-08-05 Thread Thiago Jung Bauermann
From: Ram Pai Make the Enter-Secure-Mode (ESM) ultravisor call to switch the VM to secure mode. Pass kernel base address and FDT address so that the Ultravisor is able to verify the integrity of the VM using information from the ESM blob. Add "svm=" command line option to turn on switching to

[RFC PATCH v3 03/16] powerpc: Add support for adding an ESM blob to the zImage wrapper

2019-08-05 Thread Thiago Jung Bauermann
From: Benjamin Herrenschmidt For secure VMs, the signing tool will create a ticket called the "ESM blob" for the Enter Secure Mode ultravisor call with the signatures of the kernel and initrd among other things. This adds support to the wrapper script for adding that blob via the "-e" option to

[PATCH v3 02/16] powerpc/pseries: Introduce option to build secure virtual machines

2019-08-05 Thread Thiago Jung Bauermann
Introduce CONFIG_PPC_SVM to control support for secure guests and include Ultravisor-related helpers when it is selected Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/include/asm/asm-prototypes.h | 2 +- arch/powerpc/kernel/Makefile | 4 +++-

[PATCH v3 00/16] Secure Virtual Machine Enablement

2019-08-05 Thread Thiago Jung Bauermann
Hello, There are three new patches from Claudio's "kvmppc: Paravirtualize KVM to support ultravisor" series. Two of them are borrowed (meaning that he will submit them with his series as well) and included here so that this series can stand on its own. They are the one introducing ucall_norets()

[PATCH v3 01/16] powerpc/kernel: Add ucall_norets() ultravisor call handler

2019-08-05 Thread Thiago Jung Bauermann
From: Claudio Carvalho The ultracalls (ucalls for short) allow the Secure Virtual Machines (SVM)s and hypervisor to request services from the ultravisor such as accessing a register or memory region that can only be accessed when running in ultravisor-privileged mode. This patch adds

Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-05 Thread Christoph Hellwig
On Mon, Aug 05, 2019 at 07:55:44PM -0700, Gavin Li wrote: > > /* create a coherent mapping */ > > ret = dma_common_contiguous_remap(page, size, VM_USERMAP, > > - arch_dma_mmap_pgprot(dev, PAGE_KERNEL, attrs), > > + dma_pgprot(dev,

[PATCH v4 6/6] s390/mm: Remove sev_active() function

2019-08-05 Thread Thiago Jung Bauermann
All references to sev_active() were moved to arch/x86 so we don't need to define it for s390 anymore. Signed-off-by: Thiago Jung Bauermann Reviewed-by: Christoph Hellwig Reviewed-by: Halil Pasic --- arch/s390/include/asm/mem_encrypt.h | 1 - arch/s390/mm/init.c | 7 +-- 2

[PATCH v4 5/6] fs/core/vmcore: Move sev_active() reference to x86 arch code

2019-08-05 Thread Thiago Jung Bauermann
Secure Encrypted Virtualization is an x86-specific feature, so it shouldn't appear in generic kernel code because it forces non-x86 architectures to define the sev_active() function, which doesn't make a lot of sense. To solve this problem, add an x86 elfcorehdr_read() function to override the

[PATCH v4 4/6] x86, s390/mm: Move sme_active() and sme_me_mask to x86-specific header

2019-08-05 Thread Thiago Jung Bauermann
Now that generic code doesn't reference them, move sme_active() and sme_me_mask to x86's . Also remove the export for sme_active() since it's only used in files that won't be built as modules. sme_me_mask on the other hand is used in arch/x86/kvm/svm.c (via __sme_set() and __psp_pa()) which can

[PATCH v4 2/6] swiotlb: Remove call to sme_active()

2019-08-05 Thread Thiago Jung Bauermann
sme_active() is an x86-specific function so it's better not to call it from generic code. There's no need to mention which memory encryption feature is active, so just use a more generic message. Besides, other architectures will have different names for similar technology. Signed-off-by: Thiago

[PATCH v4 3/6] dma-mapping: Remove dma_check_mask()

2019-08-05 Thread Thiago Jung Bauermann
sme_active() is an x86-specific function so it's better not to call it from generic code. Christoph Hellwig mentioned that "There is no reason why we should have a special debug printk just for one specific reason why there is a requirement for a large DMA mask.", so just remove dma_check_mask().

[PATCH v4 1/6] x86, s390: Move ARCH_HAS_MEM_ENCRYPT definition to arch/Kconfig

2019-08-05 Thread Thiago Jung Bauermann
powerpc is also going to use this feature, so put it in a generic location. Signed-off-by: Thiago Jung Bauermann Reviewed-by: Thomas Gleixner Reviewed-by: Christoph Hellwig --- arch/Kconfig | 3 +++ arch/s390/Kconfig | 4 +--- arch/x86/Kconfig | 4 +--- 3 files changed, 5 insertions(+),

[PATCH v4 0/6] Remove x86-specific code from generic headers

2019-08-05 Thread Thiago Jung Bauermann
Hello, This version has only a small change in the last patch as requested by Christoph and Halil, and collects Reviewed-by's. These patches are applied on top of v5.3-rc2. I don't have a way to test SME, SEV, nor s390's PEF so the patches have only been build tested. Changelog Since v3: -

RE: [PATCHv2 3/3] PCI: layerscape: Add LS1028a support

2019-08-05 Thread Z.q. Hou
Hi Xiaowei, > -Original Message- > From: Xiaowei Bao [mailto:xiaowei@nxp.com] > Sent: 2019年8月5日 12:05 > To: bhelg...@google.com; robh...@kernel.org; mark.rutl...@arm.com; > shawn...@kernel.org; Leo Li ; kis...@ti.com; > lorenzo.pieral...@arm.com; a...@arndb.de;

Re: [PATCH v3 0/3] Powerpc64/Watchpoint: Few important fixes

2019-08-05 Thread Ravi Bangoria
Mikey, mpe ... Any thoughts?

[PATCH] powerpc/fadump: sysfs for fadump memory reservation

2019-08-05 Thread Sourabh Jain
Add a sys interface to allow querying the memory reserved by fadump for saving the crash dump. Signed-off-by: Sourabh Jain --- Documentation/powerpc/firmware-assisted-dump.rst | 5 + arch/powerpc/kernel/fadump.c | 14 ++ 2 files changed, 19 insertions(+)

[PATCH v3 0/3] Fix oops in shared-processor spinlocks

2019-08-05 Thread Christopher M. Riedl
Fixes an oops when calling the shared-processor spinlock implementation from a non-SP LPAR. Also take this opportunity to refactor SHARED_PROCESSOR a bit. Reference: https://github.com/linuxppc/issues/issues/229 Changes since v2: - Directly call splpar_*_yield() to avoid duplicate call to

[PATCH v3 2/3] powerpc/spinlocks: Rename SPLPAR-only spinlocks

2019-08-05 Thread Christopher M. Riedl
The __rw_yield and __spin_yield locks only pertain to SPLPAR mode. Rename them to make this relationship obvious. Signed-off-by: Christopher M. Riedl Reviewed-by: Andrew Donnellan --- arch/powerpc/include/asm/spinlock.h | 6 -- arch/powerpc/lib/locks.c| 6 +++--- 2 files

[PATCH v3 3/3] powerpc/spinlocks: Fix oops in shared-processor spinlocks

2019-08-05 Thread Christopher M. Riedl
Booting w/ ppc64le_defconfig + CONFIG_PREEMPT results in the attached kernel trace due to calling shared-processor spinlocks while not running in an SPLPAR. Previously, the out-of-line spinlocks implementations were selected based on CONFIG_PPC_SPLPAR at compile time without a runtime

[PATCH v3 1/3] powerpc/spinlocks: Refactor SHARED_PROCESSOR

2019-08-05 Thread Christopher M. Riedl
Determining if a processor is in shared processor mode is not a constant so don't hide it behind a #define. Signed-off-by: Christopher M. Riedl Reviewed-by: Andrew Donnellan --- arch/powerpc/include/asm/spinlock.h | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-)

Re: [PATCH v4 00/10] implement KASLR for powerpc/fsl_booke/32

2019-08-05 Thread Jason Yan
Hi Christophe , Can you take a look at patch 6,7,9 of this version? Thank you, Jason On 2019/8/5 14:43, Jason Yan wrote: This series implements KASLR for powerpc/fsl_booke/32, as a security feature that deters exploit attempts relying on knowledge of the location of kernel internals. Since

Re: [PATCH v2 1/3] powerpc/rtas: use device model APIs and serialization during LPM

2019-08-05 Thread Tyrel Datwyler
On 8/2/19 12:29 PM, Nathan Lynch wrote: > The LPAR migration implementation and userspace-initiated cpu hotplug > can interleave their executions like so: > > 1. Set cpu 7 offline via sysfs. > > 2. Begin a partition migration, whose implementation requires the OS >to ensure all present cpus

[PATCH net-next] ibmveth: Allow users to update reported speed and duplex

2019-08-05 Thread Thomas Falcon
Reported ethtool link settings for the ibmveth driver are currently hardcoded and no longer reflect the actual capabilities of supported hardware. There is no interface designed for retrieving this information from device firmware nor is there any way to update current settings to reflect observed

Re: [PATCH v12 01/11] MODSIGN: Export module signature definitions

2019-08-05 Thread Mimi Zohar
On Mon, 2019-08-05 at 15:11 +0200, Philipp Rudo wrote: > Hi Thiago, > > > > The patch looks good now. > > > > Thanks! Can I add your Reviewed-by? > > sorry, for the late answer, but I was on vacation the last two weeks. I hope > it's not too late now. > > Reviewed-by: Philipp Rudo Thanks!  

[Bug 204479] KASAN hit at modprobe zram

2019-08-05 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=204479 --- Comment #3 from Erhard F. (erhar...@mailbox.org) --- Yes, at least one usb driver is also affected. Also radeon.ko sometimes loads ok, sometimes it stalls: # modprobe -v radeon insmod

Re: [PATCH v12 01/11] MODSIGN: Export module signature definitions

2019-08-05 Thread Philipp Rudo
Hi Thiago, > > The patch looks good now. > > Thanks! Can I add your Reviewed-by? sorry, for the late answer, but I was on vacation the last two weeks. I hope it's not too late now. Reviewed-by: Philipp Rudo

Re: [PATCH 2/3] powerpc/64s/radix: ioremap use ioremap_page_range

2019-08-05 Thread Christophe Leroy
Le 24/06/2019 à 05:12, Nicholas Piggin a écrit : Christophe Leroy's on June 20, 2019 2:25 am: Le 19/06/2019 à 05:59, Nicholas Piggin a écrit : Christophe Leroy's on June 11, 2019 4:46 pm: Le 10/06/2019 à 05:08, Nicholas Piggin a écrit : I would like to remove the early ioremap or make

Re: [PATCH v5 1/3] PM: wakeup: Add routine to help fetch wakeup source object.

2019-08-05 Thread Rafael J. Wysocki
On Wednesday, July 24, 2019 9:47:20 AM CEST Ran Wang wrote: > Some user might want to go through all registered wakeup sources > and doing things accordingly. For example, SoC PM driver might need to > do HW programming to prevent powering down specific IP which wakeup > source depending on. So

Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.3-3 tag

2019-08-05 Thread Michael Ellerman
Linus Torvalds writes: > On Sun, Aug 4, 2019 at 4:49 AM Michael Ellerman wrote: >> >> Please pull some more powerpc fixes for 5.3: > > Hmm. This was caught by the gmail spam-filter for some reason. I don't > see anything particularly different from your normal pull requests, so > don't ask me

Re: [PATCH 4/7] ALSA: pcm: use dma_can_mmap() to check if a device supports dma_mmap_*

2019-08-05 Thread Takashi Iwai
On Mon, 05 Aug 2019 11:11:56 +0200, Christoph Hellwig wrote: > > Replace the local hack with the dma_can_mmap helper to check if > a given device supports mapping DMA allocations to userspace. > > Signed-off-by: Christoph Hellwig > --- > sound/core/pcm_native.c | 5 ++--- > 1 file changed, 2

[PATCH 7/7] dma-mapping: provide a better default ->get_required_mask

2019-08-05 Thread Christoph Hellwig
Most dma_map_ops instances are IOMMUs that work perfectly fine in 32-bits of IOVA space, and the generic direct mapping code already provides its own routines that is intelligent based on the amount of memory actually present. Wire up the dma-direct routine for the ARM direct mapping code as

[PATCH 6/7] dma-mapping: remove ARCH_NO_COHERENT_DMA_MMAP

2019-08-05 Thread Christoph Hellwig
Now that we never use a default ->mmap implementation, and non-coherent architectures can control the presence of ->mmap support by enabling ARCH_HAS_DMA_COHERENT_TO_PFN for the dma direct implementation there is no need for a global config option to control the availability of dma_common_mmap.

[PATCH 5/7] m68knommu: add a pgprot_noncached stub

2019-08-05 Thread Christoph Hellwig
Provide a pgprot_noncached like all the other nommu ports so that common code can rely on it being able to be present. Note that this is generally code that is not actually run on nommu, but at least we can avoid nasty ifdefs by having a stub. Signed-off-by: Christoph Hellwig ---

[PATCH 4/7] ALSA: pcm: use dma_can_mmap() to check if a device supports dma_mmap_*

2019-08-05 Thread Christoph Hellwig
Replace the local hack with the dma_can_mmap helper to check if a given device supports mapping DMA allocations to userspace. Signed-off-by: Christoph Hellwig --- sound/core/pcm_native.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/core/pcm_native.c

[PATCH 3/7] dma-mapping: add a dma_can_mmap helper

2019-08-05 Thread Christoph Hellwig
Add a helper to check if DMA allocations for a specific device can be mapped to userspace using dma_mmap_*. Signed-off-by: Christoph Hellwig --- include/linux/dma-mapping.h | 5 + kernel/dma/mapping.c| 23 +++ 2 files changed, 28 insertions(+) diff --git

[PATCH 1/7] dma-mapping: move the dma_get_sgtable API comments from arm to common code

2019-08-05 Thread Christoph Hellwig
The comments are spot on and should be near the central API, not just near a single implementation. Signed-off-by: Christoph Hellwig --- arch/arm/mm/dma-mapping.c | 11 --- kernel/dma/mapping.c | 11 +++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git

[PATCH 2/7] dma-mapping: explicitly wire up ->mmap and ->get_sgtable

2019-08-05 Thread Christoph Hellwig
While the default ->mmap and ->get_sgtable implementations work for the majority of our dma_map_ops impementations they are inherently safe for others that don't use the page allocator or CMA and/or use their own way of remapping not covered by the common code. So remove the defaults if these

remove default fallbacks in dma_map_ops v2

2019-08-05 Thread Christoph Hellwig
Hi all, we have a few places where the DMA mapping layer has non-trivial default actions that are questionable and/or dangerous. This series instead wires up the mmap, get_sgtable and get_required_mask methods explicitly and cleans up some surrounding areas. This also means we could get rid of

Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-05 Thread Catalin Marinas
On Mon, Aug 05, 2019 at 11:01:44AM +0300, Christoph Hellwig wrote: > All the way back to introducing dma_common_mmap we've defaulyed to mark s/defaultyed/defaulted/ > the pages as uncached. But this is wrong for DMA coherent devices. > Later on DMA_ATTR_WRITE_COMBINE also got incorrect

Re: SMP lockup at boot on Freescale/NXP T2080 (powerpc 64)

2019-08-05 Thread Chris Packham
On Mon, 2019-08-05 at 14:06 +1200, Chris Packham wrote: > Hi All, > > I have a custom board that uses the Freescale/NXP T2080 SoC. > > The board boots fine using v4.19.60 but when I use v5.1.21 it locks > up > waiting for the other CPUs to come online (earlyprintk output below). > If I set

Re: [PATCH 2/2] MIPS: remove support for DMA_ATTR_WRITE_COMBINE

2019-08-05 Thread Sergei Shtylyov
Hello! On 05.08.2019 11:01, Christoph Hellwig wrote: Mips uses the KSEG1 kernel memory segment do map dma coherent MIPS. s/do/to/? allocations for n on-coherent devices as uncachable, and does not have Uncacheable? any kind of special support for DMA_ATTR_WRITE_COMBINE in the

[PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-05 Thread Christoph Hellwig
All the way back to introducing dma_common_mmap we've defaulyed to mark the pages as uncached. But this is wrong for DMA coherent devices. Later on DMA_ATTR_WRITE_COMBINE also got incorrect treatment as that flag is only treated special on the alloc side for non-coherent devices. Introduce a new

[PATCH 2/2] MIPS: remove support for DMA_ATTR_WRITE_COMBINE

2019-08-05 Thread Christoph Hellwig
Mips uses the KSEG1 kernel memory segment do map dma coherent allocations for non-coherent devices as uncachable, and does not have any kind of special support for DMA_ATTR_WRITE_COMBINE in the allocation path. Thus supporting DMA_ATTR_WRITE_COMBINE in dma_mmap_attrs will lead to multiple

fix default dma_mmap_* pgprot v2

2019-08-05 Thread Christoph Hellwig
Hi all, As Shawn pointed out we've had issues with the dma mmap pgprots ever since the dma_common_mmap helper was added beyong the initial architectures - we default to uncached mappings, but for devices that are DMA coherent, or if the DMA_ATTR_NON_CONSISTENT is set (and supported) this can lead

[Bug 204479] KASAN hit at modprobe zram

2019-08-05 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=204479 Christophe Leroy (christophe.le...@c-s.fr) changed: What|Removed |Added CC|

[PATCH v4 09/10] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter

2019-08-05 Thread Jason Yan
One may want to disable kaslr when boot, so provide a cmdline parameter 'nokaslr' to support this. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook Reviewed-by: Diana

[PATCH v4 01/10] powerpc: unify definition of M_IF_NEEDED

2019-08-05 Thread Jason Yan
M_IF_NEEDED is defined too many times. Move it to a common place. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook Reviewed-by: Christophe Leroy Reviewed-by: Diana Craciun

[PATCH v4 03/10] powerpc: introduce kimage_vaddr to store the kernel base

2019-08-05 Thread Jason Yan
Now the kernel base is a fixed value - KERNELBASE. To support KASLR, we need a variable to store the kernel base. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook

[PATCH v4 08/10] powerpc/fsl_booke/kaslr: clear the original kernel if randomized

2019-08-05 Thread Jason Yan
The original kernel still exists in the memory, clear it now. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook Reviewed-by: Christophe Leroy Reviewed-by: Diana Craciun

[PATCH v4 06/10] powerpc/fsl_booke/32: implement KASLR infrastructure

2019-08-05 Thread Jason Yan
This patch add support to boot kernel from places other than KERNELBASE. Since CONFIG_RELOCATABLE has already supported, what we need to do is map or copy kernel to a proper place and relocate. Freescale Book-E parts expect lowmem to be mapped by fixed TLB entries(TLB1). The TLB1 entries are not

[PATCH v4 07/10] powerpc/fsl_booke/32: randomize the kernel image offset

2019-08-05 Thread Jason Yan
After we have the basic support of relocate the kernel in some appropriate place, we can start to randomize the offset now. Entropy is derived from the banner and timer, which will change every build and boot. This not so much safe so additionally the bootloader may pass entropy via the

[PATCH v4 10/10] powerpc/fsl_booke/kaslr: dump out kernel offset information on panic

2019-08-05 Thread Jason Yan
When kaslr is enabled, the kernel offset is different for every boot. This brings some difficult to debug the kernel. Dump out the kernel offset when panic so that we can easily debug the kernel. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin

[PATCH v4 04/10] powerpc/fsl_booke/32: introduce create_tlb_entry() helper

2019-08-05 Thread Jason Yan
Add a new helper create_tlb_entry() to create a tlb entry by the virtual and physical address. This is a preparation to support boot kernel at a randomized address. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul

[PATCH v4 05/10] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper

2019-08-05 Thread Jason Yan
Add a new helper reloc_kernel_entry() to jump back to the start of the new kernel. After we put the new kernel in a randomized place we can use this new helper to enter the kernel and begin to relocate again. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy

[PATCH v4 00/10] implement KASLR for powerpc/fsl_booke/32

2019-08-05 Thread Jason Yan
This series implements KASLR for powerpc/fsl_booke/32, as a security feature that deters exploit attempts relying on knowledge of the location of kernel internals. Since CONFIG_RELOCATABLE has already supported, what we need to do is map or copy kernel to a proper place and relocate. Freescale

[PATCH v4 02/10] powerpc: move memstart_addr and kernstart_addr to init-common.c

2019-08-05 Thread Jason Yan
These two variables are both defined in init_32.c and init_64.c. Move them to init-common.c. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook Reviewed-by: Christophe Leroy

[PATCH v7 7/7] powerpc: add machine check safe copy_to_user

2019-08-05 Thread Santosh Sivaraj
Use memcpy_mcsafe() implementation to define copy_to_user_mcsafe() Signed-off-by: Santosh Sivaraj --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/uaccess.h | 14 ++ 2 files changed, 15 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig

[PATCH v7 6/7] powerpc/mce: Handle UE event for memcpy_mcsafe

2019-08-05 Thread Santosh Sivaraj
If we take a UE on one of the instructions with a fixup entry, set nip to continue execution at the fixup entry. Stop processing the event further or print it. Based-on-patch-by: Reza Arbab Cc: Reza Arbab Cc: Mahesh Salgaonkar Signed-off-by: Santosh Sivaraj --- arch/powerpc/include/asm/mce.h

[PATCH v7 5/7] powerpc/memcpy: Add memcpy_mcsafe for pmem

2019-08-05 Thread Santosh Sivaraj
From: Balbir Singh The pmem infrastructure uses memcpy_mcsafe in the pmem layer so as to convert machine check exceptions into a return value on failure in case a machine check exception is encountered during the memcpy. The return value is the number of bytes remaining to be copied. This patch

[PATCH v7 4/7] extable: Add function to search only kernel exception table

2019-08-05 Thread Santosh Sivaraj
Certain architecture specific operating modes (e.g., in powerpc machine check handler that is unable to access vmalloc memory), the search_exception_tables cannot be called because it also searches the module exception tables if entry is not found in the kernel exception table. Cc: Thomas

[PATCH v7 3/7] powerpc/mce: Fix MCE handling for huge pages

2019-08-05 Thread Santosh Sivaraj
From: Balbir Singh The current code would fail on huge pages addresses, since the shift would be incorrect. Use the correct page shift value returned by __find_linux_pte() to get the correct physical address. The code is more generic and can handle both regular and compound pages. Fixes:

[PATCH v7 2/7] powerpc/mce: Make machine_check_ue_event() static

2019-08-05 Thread Santosh Sivaraj
From: Reza Arbab The function doesn't get used outside this file, so make it static. Signed-off-by: Reza Arbab Signed-off-by: Santosh Sivaraj Reviewed-by: Nicholas Piggin --- arch/powerpc/kernel/mce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git

[PATCH v7 1/7] powerpc/mce: Schedule work from irq_work

2019-08-05 Thread Santosh Sivaraj
schedule_work() cannot be called from MCE exception context as MCE can interrupt even in interrupt disabled context. fixes: 733e4a4c ("powerpc/mce: hookup memory_failure for UE errors") Signed-off-by: Santosh Sivaraj --- arch/powerpc/kernel/mce.c | 8 +--- 1 file changed, 5 insertions(+), 3

[PATCH v7 0/7] powerpc: implement machine check safe memcpy

2019-08-05 Thread Santosh Sivaraj
During a memcpy from a pmem device, if a machine check exception is generated we end up in a panic. In case of fsdax read, this should only result in a -EIO. Avoid MCE by implementing memcpy_mcsafe. Before this patch series: ``` bash-4.4# mount -o dax /dev/pmem0 /mnt/pmem/ [ 7621.714094]