Centos-kernel-stream-9/drivers/virt
John Allen 51656ac86b x86/sev: Change snp_guest_issue_request()'s fw_err argument
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152249
Upstream Status: linux.git

commit 0144e3b85d7b42e8a4cda991c0e81f131897457a
Author: Dionna Glaze <dionnaglaze@google.com>
Date:   Tue Mar 7 20:24:49 2023 +0100

    x86/sev: Change snp_guest_issue_request()'s fw_err argument

    The GHCB specification declares that the firmware error value for
    a guest request will be stored in the lower 32 bits of EXIT_INFO_2.  The
    upper 32 bits are for the VMM's own error code. The fw_err argument to
    snp_guest_issue_request() is thus a misnomer, and callers will need
    access to all 64 bits.

    The type of unsigned long also causes problems, since sw_exit_info2 is
    u64 (unsigned long long) vs the argument's unsigned long*. Change this
    type for issuing the guest request. Pass the ioctl command struct's error
    field directly instead of in a local variable, since an incomplete guest
    request may not set the error code, and uninitialized stack memory would
    be written back to user space.

    The firmware might not even be called, so bookend the call with the no
    firmware call error and clear the error.

    Since the "fw_err" field is really exitinfo2 split into the upper bits'
    vmm error code and lower bits' firmware error code, convert the 64 bit
    value to a union.

      [ bp:
       - Massage commit message
       - adjust code
       - Fix a build issue as
       Reported-by: kernel test robot <lkp@intel.com>
       Link: https://lore.kernel.org/oe-kbuild-all/202303070609.vX6wp2Af-lkp@intel.com
       - print exitinfo2 in hex
       Tom:
        - Correct -EIO exit case. ]

    Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
    Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20230214164638.1189804-5-dionnaglaze@google.com
    Link: https://lore.kernel.org/r/20230307192449.24732-12-bp@alien8.de

Signed-off-by: Bandan Das <bsd@redhat.com>
Signed-off-by: John Allen <johnalle@redhat.com>
2023-07-14 15:14:54 +00:00
..
acrn all: replace find_next{,_zero}_bit with find_first{,_zero}_bit where appropriate 2022-05-11 15:07:36 -04:00
coco x86/sev: Change snp_guest_issue_request()'s fw_err argument 2023-07-14 15:14:54 +00:00
nitro_enclaves nitro_enclaves: test: Use kunit_test_suite() macro 2023-04-17 11:47:37 -06:00
vboxguest virt: vbox: Do not use wait_event_interruptible when called from kernel context 2021-01-27 14:37:02 +01:00
Kconfig virt: Add TDX guest driver 2023-01-19 09:16:47 -03:00
Makefile virt: Add TDX guest driver 2023-01-19 09:16:47 -03:00
fsl_hypervisor.c drivers/virt/fsl_hypervisor: Fix error handling path 2020-09-07 14:57:31 +02:00