lkml.org 
[lkml]   [2022]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: vmlinux.lds.h: Bug report: unable to handle page fault when start the virtual machine with qemu
On Mon, 7 Nov 2022 at 04:27, zhaowenhui (A) <zhaowenhui8@huawei.com> wrote:
>
> Hello,
>
> We compiled the kernel with x86_64_defconfig and the following configs
> from commit d4c6399900364facd84c9e35ce1540b6046c345f (vmlinux.lds.h:
> Avoid orphan section with !SMP ):
>
> CONFIG_SMP=n
> CONFIG_AMD_MEM_ENCRYPT=y
> CONFIG_HYPERVISOR_GUEST=y
> CONFIG_KVM=y
> CONFIG_PARAVIRT=y
>
> Then start virtual machine with the following command (OS: Ubuntu; Arch:
> x86-64):
>
> qemu-system-x86_64 -enable-kvm -cpu Skylake-Server -smp 10 -m 8192
> -boot menu=on,splash-time=1000 \
> -device virtio-scsi-pci \
> -initrd ${initramfs} \
> -kernel ./linux/arch/x86/boot/bzImage \
> -append "root=/dev/ram rw rdinit=/sbin/init console=tty0
> console=ttyS0,115200 earlyprintk=ttyS0 debug " \
> -nographic -vnc :18
>
> (Note: ./linux/arch/x86/boot/bzImage is the compiled kernel bzImage path
> On my machine, initramfs=./x86_procfs.cpio.gz_1 )
>
> QEMU reports an error: BUG: unable to handle page fault for address:
> ffffffff8ad01040
>
> The bug was introduced by commit d4c6399900, and the problem can be
> avoided by rolling back the patch.
> Patch link:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d4c6399900364facd84c9e35ce1540b6046c345f.
> We speculate that the problem is related to the hardware memory
> encryption feature in the virtualization scenario of the AMD platform.
>

That patch looks incorrect to me. Without CONFIG_SMP, the PERCPU
sections are not instantiated, and the only copy of those variables is
created in the ordinary .data/.bss sections

Does the change below fix the issue for you?

--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -347,6 +347,7 @@
#define DATA_DATA \
*(.xiptext) \
*(DATA_MAIN) \
+ *(.data..decrypted) \
*(.ref.data) \
*(.data..shared_aligned) /* percpu related */ \
MEM_KEEP(init.data*) \
@@ -995,7 +996,6 @@
#ifdef CONFIG_AMD_MEM_ENCRYPT
#define PERCPU_DECRYPTED_SECTION \
. = ALIGN(PAGE_SIZE); \
- *(.data..decrypted) \
*(.data..percpu..decrypted) \
. = ALIGN(PAGE_SIZE);
#else
\
 
 \ /
  Last update: 2022-11-07 17:02    [W:0.062 / U:1.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site