• Brijesh Singh's avatar
    x86/kvm: Use __bss_decrypted attribute in shared variables · 6a1cac56
    Brijesh Singh authored
    The recent removal of the memblock dependency from kvmclock caused a SEV
    guest regression because the wall_clock and hv_clock_boot variables are
    no longer mapped decrypted when SEV is active.
    
    Use the __bss_decrypted attribute to put the static wall_clock and
    hv_clock_boot in the .bss..decrypted section so that they are mapped
    decrypted during boot.
    
    In the preparatory stage of CPU hotplug, the per-cpu pvclock data pointer
    assigns either an element of the static array or dynamically allocated
    memory for the pvclock data pointer. The static array are now mapped
    decrypted but the dynamically allocated memory is not mapped decrypted.
    However, when SEV is active this memory range must be mapped decrypted.
    
    Add a function which is called after the page allocator is up, and
    allocate memory for the pvclock data pointers for the all possible cpus.
    Map this memory range as decrypted when SEV is active.
    
    Fixes: 368a540e ("x86/kvmclock: Remove memblock dependency")
    Suggested-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Cc: Tom Lendacky <thomas.lendacky@amd.com>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Sean Christopherson <sean.j.christopherson@intel.com>
    Cc: "Radim Krčmář" <rkrcmar@redhat.com>
    Cc: kvm@vger.kernel.org
    Link: https://lkml.kernel.org/r/1536932759-12905-3-git-send-email-brijesh.singh@amd.com
    6a1cac56
kvmclock.c 9.73 KB