Tom Lendacky
8458bf94b0
x86/mm: Use proper encryption attributes with /dev/mem
...
When accessing memory using /dev/mem (or /dev/kmem) use the proper
encryption attributes when mapping the memory.
To insure the proper attributes are applied when reading or writing
/dev/mem, update the xlate_dev_mem_ptr() function to use memremap()
which will essentially perform the same steps of applying __va for
RAM or using ioremap() if not RAM.
To insure the proper attributes are applied when mmapping /dev/mem,
update the phys_mem_access_prot() to call phys_mem_access_encrypted(),
a new function which will check if the memory should be mapped encrypted
or not. If it is not to be mapped encrypted then the VMA protection
value is updated to remove the encryption bit.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/c917f403ab9f61cbfd455ad6425ed8429a5e7b54.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:05 +02:00
Tom Lendacky
f2f931c681
xen/x86: Remove SME feature in PV guests
...
Xen does not currently support SME for PV guests. Clear the SME CPU
capability in order to avoid any ambiguity.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Reviewed-by: Juergen Gross <jgross@suse.com >
Cc: <xen-devel@lists.xen.org >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/3b605622a9fae5e588e5a13967120a18ec18071b.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:05 +02:00
Tom Lendacky
bba4ed011a
x86/mm, kexec: Allow kexec to be used with SME
...
Provide support so that kexec can be used to boot a kernel when SME is
enabled.
Support is needed to allocate pages for kexec without encryption. This
is needed in order to be able to reboot in the kernel in the same manner
as originally booted.
Additionally, when shutting down all of the CPUs we need to be sure to
flush the caches and then halt. This is needed when booting from a state
where SME was not active into a state where SME is active (or vice-versa).
Without these steps, it is possible for cache lines to exist for the same
physical location but tagged both with and without the encryption bit. This
can cause random memory corruption when caches are flushed depending on
which cacheline is written last.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: <kexec@lists.infradead.org >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/b95ff075db3e7cd545313f2fb609a49619a09625.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:04 +02:00
Tom Lendacky
d0ec49d4de
kvm/x86/svm: Support Secure Memory Encryption within KVM
...
Update the KVM support to work with SME. The VMCB has a number of fields
where physical addresses are used and these addresses must contain the
memory encryption mask in order to properly access the encrypted memory.
Also, use the memory encryption mask when creating and using the nested
page tables.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/89146eccfa50334409801ff20acd52a90fb5efcf.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:04 +02:00
Tom Lendacky
95cf9264d5
x86, drm, fbdev: Do not specify encrypted memory for video mappings
...
Since video memory needs to be accessed decrypted, be sure that the
memory encryption mask is not set for the video ranges.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/a19436f30424402e01f63a09b32ab103272acced.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:04 +02:00
Tom Lendacky
46d010e04a
x86/boot/realmode: Check for memory encryption on the APs
...
Add support to check if memory encryption is active in the kernel and that
it has been enabled on the AP. If memory encryption is active in the kernel
but has not been enabled on the AP, then set the memory encryption bit (bit
23) of MSR_K8_SYSCFG to enable memory encryption on that AP and allow the
AP to continue start up.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/37e29b99c395910f56ca9f8ecf7b0439b28827c8.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:04 +02:00
Tom Lendacky
2543a786aa
iommu/amd: Allow the AMD IOMMU to work with memory encryption
...
The IOMMU is programmed with physical addresses for the various tables
and buffers that are used to communicate between the device and the
driver. When the driver allocates this memory it is encrypted. In order
for the IOMMU to access the memory as encrypted the encryption mask needs
to be included in these physical addresses during configuration.
The PTE entries created by the IOMMU should also include the encryption
mask so that when the device behind the IOMMU performs a DMA, the DMA
will be performed to encrypted memory.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Acked-by: Joerg Roedel <jroedel@suse.de >
Cc: <iommu@lists.linux-foundation.org >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/3053631ea25ba8b1601c351cb7c541c496f6d9bc.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:03 +02:00
Tom Lendacky
f655e6e6b9
x86/cpu/AMD: Make the microcode level available earlier in the boot
...
Move the setting of the cpuinfo_x86.microcode field from amd_init() to
early_amd_init() so that it is available earlier in the boot process. This
avoids having to read MSR_AMD64_PATCH_LEVEL directly during early boot.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/7b7525fa12593dac5f4b01fcc25c95f97e93862f.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:03 +02:00
Tom Lendacky
648babb707
swiotlb: Add warnings for use of bounce buffers with SME
...
Add warnings to let the user know when bounce buffers are being used for
DMA when SME is active. Since the bounce buffers are not in encrypted
memory, these notifications are to allow the user to determine some
appropriate action - if necessary. Actions can range from utilizing an
IOMMU, replacing the device with another device that can support 64-bit
DMA, ignoring the message if the device isn't used much, etc.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/d112564053c3f2e86ca634a8d4fa4abc0eb53a6a.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:03 +02:00
Tom Lendacky
c7753208a9
x86, swiotlb: Add memory encryption support
...
Since DMA addresses will effectively look like 48-bit addresses when the
memory encryption mask is set, SWIOTLB is needed if the DMA mask of the
device performing the DMA does not support 48-bits. SWIOTLB will be
initialized to create decrypted bounce buffers for use by these devices.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/aa2d29b78ae7d508db8881e46a3215231b9327a7.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:03 +02:00
Tom Lendacky
163ea3c83a
x86/realmode: Decrypt trampoline area if memory encryption is active
...
When Secure Memory Encryption is enabled, the trampoline area must not
be encrypted. A CPU running in real mode will not be able to decrypt
memory that has been encrypted because it will not be able to use addresses
with the memory encryption mask.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/c70ffd2614fa77e80df31c9169ca98a9b16ff97c.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:03 +02:00
Tom Lendacky
77bd2342d4
x86/mm: Add support for changing the memory encryption attribute
...
Add support for changing the memory encryption attribute for one or more
memory pages. This will be useful when we have to change the AP trampoline
area to not be encrypted. Or when we need to change the SWIOTLB area to
not be encrypted in support of devices that can't support the encryption
mask range.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/924ae0d1f6d4c90c5a0e366c291b90a2d86aa79e.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:02 +02:00
Tom Lendacky
1de328628c
x86/mm: Add support to access persistent memory in the clear
...
Persistent memory is expected to persist across reboots. The encryption
key used by SME will change across reboots which will result in corrupted
persistent memory. Persistent memory is handed out by block devices
through memory remapping functions, so be sure not to map this memory as
encrypted.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/7d829302d8fdc85f3d9505fc3eb8ec0c3a3e1cbf.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:02 +02:00
Tom Lendacky
5997efb967
x86/boot: Use memremap() to map the MPF and MPC data
...
The SMP MP-table is built by UEFI and placed in memory in a decrypted
state. These tables are accessed using a mix of early_memremap(),
early_memunmap(), phys_to_virt() and virt_to_phys(). Change all accesses
to use early_memremap()/early_memunmap(). This allows for proper setting
of the encryption mask so that the data can be successfully accessed when
SME is active.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/d9464b0d7c861021ed8f494e4a40d6cd10f1eddd.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:02 +02:00
Tom Lendacky
8f716c9b5f
x86/mm: Add support to access boot related data in the clear
...
Boot data (such as EFI related data) is not encrypted when the system is
booted because UEFI/BIOS does not run with SME active. In order to access
this data properly it needs to be mapped decrypted.
Update early_memremap() to provide an arch specific routine to modify the
pagetable protection attributes before they are applied to the new
mapping. This is used to remove the encryption mask for boot related data.
Update memremap() to provide an arch specific routine to determine if RAM
remapping is allowed. RAM remapping will cause an encrypted mapping to be
generated. By preventing RAM remapping, ioremap_cache() will be used
instead, which will provide a decrypted mapping of the boot related data.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/81fb6b4117a5df6b9f2eda342f81bbef4b23d2e5.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:02 +02:00
Tom Lendacky
38eecccdf4
x86/efi: Update EFI pagetable creation to work with SME
...
When SME is active, pagetable entries created for EFI need to have the
encryption mask set as necessary.
When the new pagetable pages are allocated they are mapped encrypted. So,
update the efi_pgt value that will be used in CR3 to include the encryption
mask so that the PGD table can be read successfully. The pagetable mapping
as well as the kernel are also added to the pagetable mapping as encrypted.
All other EFI mappings are mapped decrypted (tables, etc.).
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/9a8f4c502db4a84b09e2f0a1555bb75aa8b69785.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:02 +02:00
Tom Lendacky
f99afd08a4
efi: Update efi_mem_type() to return an error rather than 0
...
The efi_mem_type() function currently returns a 0, which maps to
EFI_RESERVED_TYPE, if the function is unable to find a memmap entry for
the supplied physical address. Returning EFI_RESERVED_TYPE implies that
a memmap entry exists, when it doesn't. Instead of returning 0, change
the function to return a negative error value when no memmap entry is
found.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/7fbf40a9dc414d5da849e1ddcd7f7c1285e4e181.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:01 +02:00
Tom Lendacky
a19d66c56a
efi: Add an EFI table address match function
...
Add a function that will determine if a supplied physical address matches
the address of an EFI table.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/e1e06441d80f44776df391e0e4cb485b345b7518.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:01 +02:00
Tom Lendacky
d68baa3fa6
x86/boot/e820: Add support to determine the E820 type of an address
...
Add a function that will return the E820 type associated with an address
range.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/b797aaa588803bf33263d5dd8c32377668fa931a.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:01 +02:00
Tom Lendacky
b9d05200bc
x86/mm: Insure that boot memory areas are mapped properly
...
The boot data and command line data are present in memory in a decrypted
state and are copied early in the boot process. The early page fault
support will map these areas as encrypted, so before attempting to copy
them, add decrypted mappings so the data is accessed properly when copied.
For the initrd, encrypt this data in place. Since the future mapping of
the initrd area will be mapped as encrypted the data will be accessed
properly.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/bb0d430b41efefd45ee515aaf0979dcfda8b6a44.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:01 +02:00
Tom Lendacky
7f8b7e7f4c
x86/mm: Add support for early encryption/decryption of memory
...
Add support to be able to either encrypt or decrypt data in place during
the early stages of booting the kernel. This does not change the memory
encryption attribute - it is used for ensuring that data present in either
an encrypted or decrypted memory area is in the proper state (for example
the initrd will have been loaded by the boot loader and will not be
encrypted, but the memory that it resides in is marked as encrypted).
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/f9968e9432cd6c4b57ef245729be04ff18852225.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:01 +02:00
Tom Lendacky
f88a68facd
x86/mm: Extend early_memremap() support with additional attrs
...
Add early_memremap() support to be able to specify encrypted and
decrypted mappings with and without write-protection. The use of
write-protection is necessary when encrypting data "in place". The
write-protect attribute is considered cacheable for loads, but not
stores. This implies that the hardware will never give the core a
dirty line with this memtype.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/479b5832c30fae3efa7932e48f81794e86397229.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:00 +02:00
Tom Lendacky
eef9c4abe7
x86/mm: Add SME support for read_cr3_pa()
...
The CR3 register entry can contain the SME encryption mask that indicates
the PGD is encrypted. The encryption mask should not be used when
creating a virtual address from the CR3 register, so remove the SME
encryption mask in the read_cr3_pa() function.
During early boot SME will need to use a native version of read_cr3_pa(),
so create native_read_cr3_pa().
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/767b085c384a46f67f451f8589903a462c7ff68a.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:00 +02:00
Tom Lendacky
21729f81ce
x86/mm: Provide general kernel support for memory encryption
...
Changes to the existing page table macros will allow the SME support to
be enabled in a simple fashion with minimal changes to files that use these
macros. Since the memory encryption mask will now be part of the regular
pagetable macros, we introduce two new macros (_PAGE_TABLE_NOENC and
_KERNPG_TABLE_NOENC) to allow for early pagetable creation/initialization
without the encryption mask before SME becomes active. Two new pgprot()
macros are defined to allow setting or clearing the page encryption mask.
The FIXMAP_PAGE_NOCACHE define is introduced for use with MMIO. SME does
not support encryption for MMIO areas so this define removes the encryption
mask from the page attribute.
Two new macros are introduced (__sme_pa() / __sme_pa_nodebug()) to allow
creating a physical address with the encryption mask. These are used when
working with the cr3 register so that the PGD can be encrypted. The current
__va() macro is updated so that the virtual address is generated based off
of the physical address without the encryption mask thus allowing the same
virtual address to be generated regardless of whether encryption is enabled
for that physical location or not.
Also, an early initialization function is added for SME. If SME is active,
this function:
- Updates the early_pmd_flags so that early page faults create mappings
with the encryption mask.
- Updates the __supported_pte_mask to include the encryption mask.
- Updates the protection_map entries to include the encryption mask so
that user-space allocations will automatically have the encryption mask
applied.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/b36e952c4c39767ae7f0a41cf5345adf27438480.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:00 +02:00
Tom Lendacky
fd7e315988
x86/mm: Simplify p[g4um]d_page() macros
...
Create a pgd_pfn() macro similar to the p[4um]d_pfn() macros and then
use the p[g4um]d_pfn() macros in the p[g4um]d_page() macros instead of
duplicating the code.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/e61eb533a6d0aac941db2723d8aa63ef6b882dee.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:38:00 +02:00
Tom Lendacky
5868f3651f
x86/mm: Add support to enable SME in early boot processing
...
Add support to the early boot code to use Secure Memory Encryption (SME).
Since the kernel has been loaded into memory in a decrypted state, encrypt
the kernel in place and update the early pagetables with the memory
encryption mask so that new pagetable entries will use memory encryption.
The routines to set the encryption mask and perform the encryption are
stub routines for now with functionality to be added in a later patch.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/e52ad781f085224bf835b3caff9aa3aee6febccb.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:59 +02:00
Tom Lendacky
33c2b803ed
x86/mm: Remove phys_to_virt() usage in ioremap()
...
Currently there is a check if the address being mapped is in the ISA
range (is_ISA_range()), and if it is, then phys_to_virt() is used to
perform the mapping. When SME is active, the default is to add pagetable
mappings with the encryption bit set unless specifically overridden. The
resulting pagetable mapping from phys_to_virt() will result in a mapping
that has the encryption bit set. With SME, the use of ioremap() is
intended to generate pagetable mappings that do not have the encryption
bit set through the use of the PAGE_KERNEL_IO protection value.
Rather than special case the SME scenario, remove the ISA range check and
usage of phys_to_virt() and have ISA range mappings continue through the
remaining ioremap() path.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/88ada7b09c6568c61cd696351eb59fb15a82ce1a.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:59 +02:00
Tom Lendacky
7744ccdbc1
x86/mm: Add Secure Memory Encryption (SME) support
...
Add support for Secure Memory Encryption (SME). This initial support
provides a Kconfig entry to build the SME support into the kernel and
defines the memory encryption mask that will be used in subsequent
patches to mark pages as encrypted.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/a6c34d16caaed3bc3e2d6f0987554275bd291554.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:59 +02:00
Tom Lendacky
9af9b94068
x86/cpu/AMD: Handle SME reduction in physical address size
...
When System Memory Encryption (SME) is enabled, the physical address
space is reduced. Adjust the x86_phys_bits value to reflect this
reduction.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/593c037a3cad85ba92f3d061ffa7462e9ce3531d.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:59 +02:00
Tom Lendacky
872cbefd2d
x86/cpu/AMD: Add the Secure Memory Encryption CPU feature
...
Update the CPU features to include identifying and reporting on the
Secure Memory Encryption (SME) feature. SME is identified by CPUID
0x8000001f, but requires BIOS support to enable it (set bit 23 of
MSR_K8_SYSCFG). Only show the SME feature as available if reported by
CPUID, enabled by BIOS and not configured as CONFIG_X86_32=y.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/85c17ff450721abccddc95e611ae8df3f4d9718b.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:59 +02:00
Tom Lendacky
f7750a7956
x86, mpparse, x86/acpi, x86/PCI, x86/dmi, SFI: Use memremap() for RAM mappings
...
The ioremap() function is intended for mapping MMIO. For RAM, the
memremap() function should be used. Convert calls from ioremap() to
memremap() when re-mapping RAM.
This will be used later by SME to control how the encryption mask is
applied to memory mappings, with certain memory locations being mapped
decrypted vs encrypted.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/b13fccb9abbd547a7eef7b1fdfc223431b211c88.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:58 +02:00
Tom Lendacky
aac7b79eea
x86/mm/pat: Set write-protect cache mode for full PAT support
...
For processors that support PAT, set the write-protect cache mode
(_PAGE_CACHE_MODE_WP) entry to the actual write-protect value (x05).
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Acked-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/ade53b63d4dbffbfc3cb08fb62024647059c8688.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:58 +02:00
Tom Lendacky
c262f3b9a3
x86/cpu/AMD: Document AMD Secure Memory Encryption (SME)
...
Create a Documentation entry to describe the AMD Secure Memory
Encryption (SME) feature and add documentation for the mem_encrypt=
kernel parameter.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brijesh Singh <brijesh.singh@amd.com >
Cc: Dave Young <dyoung@redhat.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Jonathan Corbet <corbet@lwn.net >
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com >
Cc: Larry Woodman <lwoodman@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matt Fleming <matt@codeblueprint.co.uk >
Cc: Michael S. Tsirkin <mst@redhat.com >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Radim Krčmář <rkrcmar@redhat.com >
Cc: Rik van Riel <riel@redhat.com >
Cc: Toshimitsu Kani <toshi.kani@hpe.com >
Cc: kasan-dev@googlegroups.com
Cc: kvm@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/ca0a0c13b055fd804cfc92cbaca8acd68057eed0.1500319216.git.thomas.lendacky@amd.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:37:58 +02:00
Ingo Molnar
1ed7d32763
Merge branch 'x86/boot' into x86/mm, to pick up interacting changes
...
The SME patches we are about to apply add some E820 logic, so merge in
pending E820 code changes first, to have a single code base.
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:36:53 +02:00
Baoquan He
27aac20574
x86/boot/KASLR: Rename process_e820_entry() into process_mem_region()
...
Now process_e820_entry() is not limited to e820 entry processing, rename
it to process_mem_region(). And adjust the code comment accordingly.
Signed-off-by: Baoquan He <bhe@redhat.com >
Acked-by: Kees Cook <keescook@chromium.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: fanc.fnst@cn.fujitsu.com
Cc: izumi.taku@jp.fujitsu.com
Cc: matt@codeblueprint.co.uk
Cc: thgarnie@google.com
Link: http://lkml.kernel.org/r/1499603862-11516-4-git-send-email-bhe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:11:12 +02:00
Baoquan He
87891b01b5
x86/boot/KASLR: Switch to pass struct mem_vector to process_e820_entry()
...
This makes process_e820_entry() be able to process any kind of memory
region.
Signed-off-by: Baoquan He <bhe@redhat.com >
Acked-by: Kees Cook <keescook@chromium.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: fanc.fnst@cn.fujitsu.com
Cc: izumi.taku@jp.fujitsu.com
Cc: matt@codeblueprint.co.uk
Cc: thgarnie@google.com
Link: http://lkml.kernel.org/r/1499603862-11516-3-git-send-email-bhe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:11:11 +02:00
Baoquan He
f62995c92a
x86/boot/KASLR: Wrap e820 entries walking code into new function process_e820_entries()
...
The original function process_e820_entry() only takes care of each
e820 entry passed.
And move the E820_TYPE_RAM checking logic into process_e820_entries().
And remove the redundent local variable 'addr' definition in
find_random_phys_addr().
Signed-off-by: Baoquan He <bhe@redhat.com >
Acked-by: Kees Cook <keescook@chromium.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: fanc.fnst@cn.fujitsu.com
Cc: izumi.taku@jp.fujitsu.com
Cc: matt@codeblueprint.co.uk
Cc: thgarnie@google.com
Link: http://lkml.kernel.org/r/1499603862-11516-2-git-send-email-bhe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-18 11:11:11 +02:00
Linus Torvalds
cb8c65ccff
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
...
Pull sparc fixes from David Miller:
- Fix DMA regression in 4.13 merge window, only certain chips can do
64-bit DMA. From Dave Dushar.
- Correct cpu cross-call algorithm to correctly detect stalled or stuck
remote cpus, from Jane Chu.
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc:
sparc64: Measure receiver forward progress to avoid send mondo timeout
SPARC64: Fix sun4v DMA panic
2017-07-17 15:08:29 -07:00
Linus Torvalds
935acd3f5e
Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
...
Pull irq fix from Thomas Gleixner:
"Fix the fallout from reworking the locking and resource management in
request/free_irq()"
* 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
genirq: Keep chip buslock across irq_request/release_resources()
2017-07-17 13:00:36 -07:00
Linus Torvalds
31ba04d99a
Merge branch 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
...
Pull SMP fix from Thomas Gleixner:
"Replace the bogus BUG_ON in the cpu hotplug code"
* 'smp-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
smp/hotplug: Replace BUG_ON and react useful
2017-07-17 12:54:51 -07:00
Linus Torvalds
338a57d5cb
Merge tag 'regmap-fix-w1-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
...
Pull regmap fix from Mark Brown:
"Fix build due to w1 header refactoring
The regmap support for w1 was added shortly before a reorganization of
the w1 headers. While this was noticed before the merge window and
efforts made to get it resolved in what was sent that managed to fall
through the cracks, this cleans up and updates things so we look for
the header in the new location.
It didn't cause build failures as the driver that's going to be the
first user got held up with other review issues"
* tag 'regmap-fix-w1-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
regmap: regmap-w1: Fix build troubles
2017-07-17 12:38:18 -07:00
Linus Torvalds
e8e9941b17
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
...
Pull SCSI fixes from James Bottomley:
"This is actually just a small set of mainly bug fixes for the original
merge window code plus a few trivial updates and qedi boot from SAN
support feature patch"
* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
scsi: libfc: pass an error pointer to fc_disc_error()
scsi: hisi_sas: make several const arrays static
scsi: qla2xxx: Off by one in qlt_ctio_to_cmd()
scsi: sg: fix SG_DXFER_FROM_DEV transfers
scsi: virtio_scsi: always read VPD pages for multiqueue too
scsi: qedf: fix spelling mistake: "offlading" -> "offloading"
scsi: qedi: fix another spelling mistake: "alloction" -> "allocation"
scsi: isci: fix typo in function names
scsi: cxlflash: return -EFAULT if copy_from_user() fails
scsi: qedi: Add support for Boot from SAN over iSCSI offload
2017-07-17 12:26:12 -07:00
Geert Uytterhoeven
cb0fbbf22a
Blackfin: flat: Use %x to format u32
...
Several variables had their types changed from unsigned long to u32,
but the printk()-style format to print them wasn't updated, leading to:
arch/blackfin/kernel/flat.c: In function 'bfin_get_addr_from_rp':
arch/blackfin/kernel/flat.c:35:3: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'u32' [-Wformat]
arch/blackfin/kernel/flat.c: In function 'bfin_put_addr_at_rp':
arch/blackfin/kernel/flat.c:80:3: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'u32' [-Wformat]
Fixes: 468138d785 ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-07-17 11:40:33 -07:00
minimumlaw@rambler.ru
5b20a43683
regmap: regmap-w1: Fix build troubles
...
Fixes: cc5d0db390 ("regmap: Add 1-Wire bus support")
Commit de0d6dbdbd ("w1: Add subsystem kernel public interface")
Fix place off w1.h header file
Cosmetic: Fix company name (local to international)
Signed-off-by: Alex A. Mihaylov <minimumlaw@rambler.ru >
Signed-off-by: Mark Brown <broonie@kernel.org >
2017-07-17 15:53:00 +01:00
Geert Uytterhoeven
87b2c3fc63
h8300: Add missing closing parenthesis in flat_get_addr_from_rp()
...
In file included from include/linux/flat.h:13:0,
from fs/binfmt_flat.c:36:
arch/h8300/include/asm/flat.h: In function 'flat_get_addr_from_rp':
arch/h8300/include/asm/flat.h:28:3: error: expected ')' before 'val'
val &= 0x00ffffff;
^
arch/h8300/include/asm/flat.h:31:1: error: expected expression before '}' token
}
^
In file included from include/linux/flat.h:13:0,
from fs/binfmt_flat.c:36:
arch/h8300/include/asm/flat.h:26:6: warning: unused variable 'val' [-Wunused-variable]
u32 val = get_unaligned((__force u32 *)rp);
^
In file included from include/linux/flat.h:13:0,
from fs/binfmt_flat.c:36:
arch/h8300/include/asm/flat.h:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
Reported-by: kbuild test robot <fengguang.wu@intel.com >
Fixes: 468138d785 ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-07-16 09:24:06 -07:00
Geert Uytterhoeven
9f42ef4bc2
blackfin, m68k: Fix flat_set_persistent() for unsigned long to u32 changes
...
Several variables had their types changed from unsigned long to u32, but
the arch-specific implementations of flat_set_persistent() weren't
updated, leading to compiler warnings on blackfin and m68k:
fs/binfmt_flat.c: In function ‘load_flat_file’:
fs/binfmt_flat.c:799: warning: passing argument 2 of ‘flat_set_persistent’ from incompatible pointer type
Fixes: 468138d785 ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-07-16 09:24:06 -07:00
Geert Uytterhoeven
a86054236d
binfmt_flat: Use %u to format u32
...
Several variables had their types changed from unsigned long to u32, but
the printk()-style format to print them wasn't updated, leading to:
fs/binfmt_flat.c: In function ‘load_flat_file’:
fs/binfmt_flat.c:577: warning: format ‘%ld’ expects type ‘long int’, but argument 3 has type ‘u32’
Fixes: 468138d785 ("binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2017-07-16 09:24:05 -07:00
Linus Torvalds
5771a8c088
Linux v4.13-rc1
v4.13-rc1
2017-07-15 15:22:10 -07:00
Linus Torvalds
486088bc46
Merge tag 'standardize-docs' of git://git.lwn.net/linux
...
Pull documentation format standardization from Jonathan Corbet:
"This series converts a number of top-level documents to the RST format
without incorporating them into the Sphinx tree. The hope is to bring
some uniformity to kernel documentation and, perhaps more importantly,
have our existing docs serve as an example of the desired formatting
for those that will be added later.
Mauro has gone through and fixed up a lot of top-level documentation
files to make them conform to the RST format, but without moving or
renaming them in any way. This will help when we incorporate the ones
we want to keep into the Sphinx doctree, but the real purpose is to
bring a bit of uniformity to our documentation and let the top-level
docs serve as examples for those writing new ones"
* tag 'standardize-docs' of git://git.lwn.net/linux: (84 commits)
docs: kprobes.txt: Fix whitespacing
tee.txt: standardize document format
cgroup-v2.txt: standardize document format
dell_rbu.txt: standardize document format
zorro.txt: standardize document format
xz.txt: standardize document format
xillybus.txt: standardize document format
vfio.txt: standardize document format
vfio-mediated-device.txt: standardize document format
unaligned-memory-access.txt: standardize document format
this_cpu_ops.txt: standardize document format
svga.txt: standardize document format
static-keys.txt: standardize document format
smsc_ece1099.txt: standardize document format
SM501.txt: standardize document format
siphash.txt: standardize document format
sgi-ioc4.txt: standardize document format
SAK.txt: standardize document format
rpmsg.txt: standardize document format
robust-futexes.txt: standardize document format
...
2017-07-15 12:58:58 -07:00
Linus Torvalds
52f6c588c7
Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
...
Pull random updates from Ted Ts'o:
"Add wait_for_random_bytes() and get_random_*_wait() functions so that
callers can more safely get random bytes if they can block until the
CRNG is initialized.
Also print a warning if get_random_*() is called before the CRNG is
initialized. By default, only one single-line warning will be printed
per boot. If CONFIG_WARN_ALL_UNSEEDED_RANDOM is defined, then a
warning will be printed for each function which tries to get random
bytes before the CRNG is initialized. This can get spammy for certain
architecture types, so it is not enabled by default"
* tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
random: reorder READ_ONCE() in get_random_uXX
random: suppress spammy warnings about unseeded randomness
random: warn when kernel uses unseeded randomness
net/route: use get_random_int for random counter
net/neighbor: use get_random_u32 for 32-bit hash random
rhashtable: use get_random_u32 for hash_rnd
ceph: ensure RNG is seeded before using
iscsi: ensure RNG is seeded before use
cifs: use get_random_u32 for 32-bit lock random
random: add get_random_{bytes,u32,u64,int,long,once}_wait family
random: add wait_for_random_bytes() API
2017-07-15 12:44:02 -07:00