]> Git Repo - J-linux.git/commitdiff
Merge branch 'kvm-6.11-sev-attestation' into HEAD
authorPaolo Bonzini <[email protected]>
Tue, 16 Jul 2024 15:44:23 +0000 (11:44 -0400)
committerPaolo Bonzini <[email protected]>
Tue, 16 Jul 2024 15:44:23 +0000 (11:44 -0400)
The GHCB 2.0 specification defines 2 GHCB request types to allow SNP guests
to send encrypted messages/requests to firmware: SNP Guest Requests and SNP
Extended Guest Requests. These encrypted messages are used for things like
servicing attestation requests issued by the guest. Implementing support for
these is required to be fully GHCB-compliant.

For the most part, KVM only needs to handle forwarding these requests to
firmware (to be issued via the SNP_GUEST_REQUEST firmware command defined
in the SEV-SNP Firmware ABI), and then forwarding the encrypted response to
the guest.

However, in the case of SNP Extended Guest Requests, the host is also
able to provide the certificate data corresponding to the endorsement key
used by firmware to sign attestation report requests. This certificate data
is provided by userspace because:

  1) It allows for different keys/key types to be used for each particular
     guest with requiring any sort of KVM API to configure the certificate
     table in advance on a per-guest basis.

  2) It provides additional flexibility with how attestation requests might
     be handled during live migration where the certificate data for
     source/dest might be different.

  3) It allows all synchronization between certificates and firmware/signing
     key updates to be handled purely by userspace rather than requiring
     some in-kernel mechanism to facilitate it. [1]

To support fetching certificate data from userspace, a new KVM exit type will
be needed to handle fetching the certificate from userspace. An attempt to
define a new KVM_EXIT_COCO/KVM_EXIT_COCO_REQ_CERTS exit type to handle this
was introduced in v1 of this patchset, but is still being discussed by
community, so for now this patchset only implements a stub version of SNP
Extended Guest Requests that does not provide certificate data, but is still
enough to provide compliance with the GHCB 2.0 spec.

1  2 
arch/x86/include/asm/sev.h
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.h
drivers/virt/coco/sev-guest/sev-guest.c

index 1936f37e3371bbfefebd64ded810d7b9b7dff9aa,d000f8c4c9452ef077615aa63815532ee5398cf1..72f9ba3a2fee1a9194cdc9770ee26fa2a12ebb24
@@@ -119,6 -119,54 +119,54 @@@ struct snp_req_data 
        unsigned int data_npages;
  };
  
+ #define MAX_AUTHTAG_LEN               32
+ /* See SNP spec SNP_GUEST_REQUEST section for the structure */
+ enum msg_type {
+       SNP_MSG_TYPE_INVALID = 0,
+       SNP_MSG_CPUID_REQ,
+       SNP_MSG_CPUID_RSP,
+       SNP_MSG_KEY_REQ,
+       SNP_MSG_KEY_RSP,
+       SNP_MSG_REPORT_REQ,
+       SNP_MSG_REPORT_RSP,
+       SNP_MSG_EXPORT_REQ,
+       SNP_MSG_EXPORT_RSP,
+       SNP_MSG_IMPORT_REQ,
+       SNP_MSG_IMPORT_RSP,
+       SNP_MSG_ABSORB_REQ,
+       SNP_MSG_ABSORB_RSP,
+       SNP_MSG_VMRK_REQ,
+       SNP_MSG_VMRK_RSP,
+       SNP_MSG_TYPE_MAX
+ };
+ enum aead_algo {
+       SNP_AEAD_INVALID,
+       SNP_AEAD_AES_256_GCM,
+ };
+ struct snp_guest_msg_hdr {
+       u8 authtag[MAX_AUTHTAG_LEN];
+       u64 msg_seqno;
+       u8 rsvd1[8];
+       u8 algo;
+       u8 hdr_version;
+       u16 hdr_sz;
+       u8 msg_type;
+       u8 msg_version;
+       u16 msg_sz;
+       u32 rsvd2;
+       u8 msg_vmpck;
+       u8 rsvd3[35];
+ } __packed;
+ struct snp_guest_msg {
+       struct snp_guest_msg_hdr hdr;
+       u8 payload[4000];
+ } __packed;
  struct sev_guest_platform_data {
        u64 secrets_gpa;
  };
@@@ -143,7 -191,7 +191,7 @@@ struct secrets_os_area 
  #define VMPCK_KEY_LEN         32
  
  /* See the SNP spec version 0.9 for secrets page format */
 -struct snp_secrets_page_layout {
 +struct snp_secrets_page {
        u32 version;
        u32 imien       : 1,
            rsvd1       : 31;
diff --combined arch/x86/kvm/svm/sev.c
index 43a450fb01fdf82cb842e5a10f8118106626d1b2,4288e9eebe05ca64585fdb48548bde84f3bdef11..a16c873b32321802372d87dadd4c062e5bd55171
@@@ -19,6 -19,7 +19,7 @@@
  #include <linux/misc_cgroup.h>
  #include <linux/processor.h>
  #include <linux/trace_events.h>
+ #include <uapi/linux/sev-guest.h>
  
  #include <asm/pkru.h>
  #include <asm/trapnr.h>
@@@ -326,6 -327,78 +327,78 @@@ static void sev_unbind_asid(struct kvm 
        sev_decommission(handle);
  }
  
+ /*
+  * This sets up bounce buffers/firmware pages to handle SNP Guest Request
+  * messages (e.g. attestation requests). See "SNP Guest Request" in the GHCB
+  * 2.0 specification for more details.
+  *
+  * Technically, when an SNP Guest Request is issued, the guest will provide its
+  * own request/response pages, which could in theory be passed along directly
+  * to firmware rather than using bounce pages. However, these pages would need
+  * special care:
+  *
+  *   - Both pages are from shared guest memory, so they need to be protected
+  *     from migration/etc. occurring while firmware reads/writes to them. At a
+  *     minimum, this requires elevating the ref counts and potentially needing
+  *     an explicit pinning of the memory. This places additional restrictions
+  *     on what type of memory backends userspace can use for shared guest
+  *     memory since there is some reliance on using refcounted pages.
+  *
+  *   - The response page needs to be switched to Firmware-owned[1] state
+  *     before the firmware can write to it, which can lead to potential
+  *     host RMP #PFs if the guest is misbehaved and hands the host a
+  *     guest page that KVM might write to for other reasons (e.g. virtio
+  *     buffers/etc.).
+  *
+  * Both of these issues can be avoided completely by using separately-allocated
+  * bounce pages for both the request/response pages and passing those to
+  * firmware instead. So that's what is being set up here.
+  *
+  * Guest requests rely on message sequence numbers to ensure requests are
+  * issued to firmware in the order the guest issues them, so concurrent guest
+  * requests generally shouldn't happen. But a misbehaved guest could issue
+  * concurrent guest requests in theory, so a mutex is used to serialize
+  * access to the bounce buffers.
+  *
+  * [1] See the "Page States" section of the SEV-SNP Firmware ABI for more
+  *     details on Firmware-owned pages, along with "RMP and VMPL Access Checks"
+  *     in the APM for details on the related RMP restrictions.
+  */
+ static int snp_guest_req_init(struct kvm *kvm)
+ {
+       struct kvm_sev_info *sev = to_kvm_sev_info(kvm);
+       struct page *req_page;
+       req_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
+       if (!req_page)
+               return -ENOMEM;
+       sev->guest_resp_buf = snp_alloc_firmware_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
+       if (!sev->guest_resp_buf) {
+               __free_page(req_page);
+               return -EIO;
+       }
+       sev->guest_req_buf = page_address(req_page);
+       mutex_init(&sev->guest_req_mutex);
+       return 0;
+ }
+ static void snp_guest_req_cleanup(struct kvm *kvm)
+ {
+       struct kvm_sev_info *sev = to_kvm_sev_info(kvm);
+       if (sev->guest_resp_buf)
+               snp_free_firmware_page(sev->guest_resp_buf);
+       if (sev->guest_req_buf)
+               __free_page(virt_to_page(sev->guest_req_buf));
+       sev->guest_req_buf = NULL;
+       sev->guest_resp_buf = NULL;
+ }
  static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp,
                            struct kvm_sev_init *data,
                            unsigned long vm_type)
        if (ret)
                goto e_free;
  
+       /* This needs to happen after SEV/SNP firmware initialization. */
+       if (vm_type == KVM_X86_SNP_VM && snp_guest_req_init(kvm))
+               goto e_free;
        INIT_LIST_HEAD(&sev->regions_list);
        INIT_LIST_HEAD(&sev->mirror_vms);
        sev->need_init = false;
@@@ -859,14 -936,6 +936,14 @@@ static int __sev_launch_update_vmsa(str
         */
        fpstate_set_confidential(&vcpu->arch.guest_fpu);
        vcpu->arch.guest_state_protected = true;
 +
 +      /*
 +       * SEV-ES guest mandates LBR Virtualization to be _always_ ON. Enable it
 +       * only after setting guest_state_protected because KVM_SET_MSRS allows
 +       * dynamic toggling of LBRV (for performance reason) on write access to
 +       * MSR_IA32_DEBUGCTLMSR when guest_state_protected is not set.
 +       */
 +      svm_enable_lbrv(vcpu);
        return 0;
  }
  
@@@ -2402,14 -2471,6 +2479,14 @@@ static int snp_launch_update_vmsa(struc
                }
  
                svm->vcpu.arch.guest_state_protected = true;
 +              /*
 +               * SEV-ES (and thus SNP) guest mandates LBR Virtualization to
 +               * be _always_ ON. Enable it only after setting
 +               * guest_state_protected because KVM_SET_MSRS allows dynamic
 +               * toggling of LBRV (for performance reason) on write access to
 +               * MSR_IA32_DEBUGCTLMSR when guest_state_protected is not set.
 +               */
 +              svm_enable_lbrv(vcpu);
        }
  
        return 0;
@@@ -2850,6 -2911,8 +2927,8 @@@ void sev_vm_destroy(struct kvm *kvm
        }
  
        if (sev_snp_guest(kvm)) {
+               snp_guest_req_cleanup(kvm);
                /*
                 * Decomission handles unbinding of the ASID. If it fails for
                 * some unexpected reason, just leak the ASID.
@@@ -2956,12 -3019,6 +3035,12 @@@ void __init sev_hardware_setup(void
        if (!boot_cpu_has(X86_FEATURE_SEV_ES))
                goto out;
  
 +      if (!lbrv) {
 +              WARN_ONCE(!boot_cpu_has(X86_FEATURE_LBRV),
 +                        "LBRV must be present for SEV-ES support");
 +              goto out;
 +      }
 +
        /* Has the system been allocated ASIDs for SEV-ES? */
        if (min_sev_asid == 1)
                goto out;
@@@ -3321,6 -3378,14 +3400,14 @@@ static int sev_es_validate_vmgexit(stru
                if (!sev_snp_guest(vcpu->kvm) || !kvm_ghcb_sw_scratch_is_valid(svm))
                        goto vmgexit_err;
                break;
+       case SVM_VMGEXIT_GUEST_REQUEST:
+       case SVM_VMGEXIT_EXT_GUEST_REQUEST:
+               if (!sev_snp_guest(vcpu->kvm) ||
+                   !PAGE_ALIGNED(control->exit_info_1) ||
+                   !PAGE_ALIGNED(control->exit_info_2) ||
+                   control->exit_info_1 == control->exit_info_2)
+                       goto vmgexit_err;
+               break;
        default:
                reason = GHCB_ERR_INVALID_EVENT;
                goto vmgexit_err;
        return ret;
  }
  
+ static int snp_handle_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_gpa)
+ {
+       struct sev_data_snp_guest_request data = {0};
+       struct kvm *kvm = svm->vcpu.kvm;
+       struct kvm_sev_info *sev = to_kvm_sev_info(kvm);
+       sev_ret_code fw_err = 0;
+       int ret;
+       if (!sev_snp_guest(kvm))
+               return -EINVAL;
+       mutex_lock(&sev->guest_req_mutex);
+       if (kvm_read_guest(kvm, req_gpa, sev->guest_req_buf, PAGE_SIZE)) {
+               ret = -EIO;
+               goto out_unlock;
+       }
+       data.gctx_paddr = __psp_pa(sev->snp_context);
+       data.req_paddr = __psp_pa(sev->guest_req_buf);
+       data.res_paddr = __psp_pa(sev->guest_resp_buf);
+       /*
+        * Firmware failures are propagated on to guest, but any other failure
+        * condition along the way should be reported to userspace. E.g. if
+        * the PSP is dead and commands are timing out.
+        */
+       ret = sev_issue_cmd(kvm, SEV_CMD_SNP_GUEST_REQUEST, &data, &fw_err);
+       if (ret && !fw_err)
+               goto out_unlock;
+       if (kvm_write_guest(kvm, resp_gpa, sev->guest_resp_buf, PAGE_SIZE)) {
+               ret = -EIO;
+               goto out_unlock;
+       }
+       ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, SNP_GUEST_ERR(0, fw_err));
+       ret = 1; /* resume guest */
+ out_unlock:
+       mutex_unlock(&sev->guest_req_mutex);
+       return ret;
+ }
+ static int snp_handle_ext_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_gpa)
+ {
+       struct kvm *kvm = svm->vcpu.kvm;
+       u8 msg_type;
+       if (!sev_snp_guest(kvm))
+               return -EINVAL;
+       if (kvm_read_guest(kvm, req_gpa + offsetof(struct snp_guest_msg_hdr, msg_type),
+                          &msg_type, 1))
+               return -EIO;
+       /*
+        * As per GHCB spec, requests of type MSG_REPORT_REQ also allow for
+        * additional certificate data to be provided alongside the attestation
+        * report via the guest-provided data pages indicated by RAX/RBX. The
+        * certificate data is optional and requires additional KVM enablement
+        * to provide an interface for userspace to provide it, but KVM still
+        * needs to be able to handle extended guest requests either way. So
+        * provide a stub implementation that will always return an empty
+        * certificate table in the guest-provided data pages.
+        */
+       if (msg_type == SNP_MSG_REPORT_REQ) {
+               struct kvm_vcpu *vcpu = &svm->vcpu;
+               u64 data_npages;
+               gpa_t data_gpa;
+               if (!kvm_ghcb_rax_is_valid(svm) || !kvm_ghcb_rbx_is_valid(svm))
+                       goto request_invalid;
+               data_gpa = vcpu->arch.regs[VCPU_REGS_RAX];
+               data_npages = vcpu->arch.regs[VCPU_REGS_RBX];
+               if (!PAGE_ALIGNED(data_gpa))
+                       goto request_invalid;
+               /*
+                * As per GHCB spec (see "SNP Extended Guest Request"), the
+                * certificate table is terminated by 24-bytes of zeroes.
+                */
+               if (data_npages && kvm_clear_guest(kvm, data_gpa, 24))
+                       return -EIO;
+       }
+       return snp_handle_guest_req(svm, req_gpa, resp_gpa);
+ request_invalid:
+       ghcb_set_sw_exit_info_1(svm->sev_es.ghcb, 2);
+       ghcb_set_sw_exit_info_2(svm->sev_es.ghcb, GHCB_ERR_INVALID_INPUT);
+       return 1; /* resume guest */
+ }
  static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm)
  {
        struct vmcb_control_area *control = &svm->vmcb->control;
@@@ -4213,6 -4375,12 +4397,12 @@@ int sev_handle_vmgexit(struct kvm_vcpu 
  
                ret = 1;
                break;
+       case SVM_VMGEXIT_GUEST_REQUEST:
+               ret = snp_handle_guest_req(svm, control->exit_info_1, control->exit_info_2);
+               break;
+       case SVM_VMGEXIT_EXT_GUEST_REQUEST:
+               ret = snp_handle_ext_guest_req(svm, control->exit_info_1, control->exit_info_2);
+               break;
        case SVM_VMGEXIT_UNSUPPORTED_EVENT:
                vcpu_unimpl(vcpu,
                            "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",
@@@ -4298,6 -4466,7 +4488,6 @@@ static void sev_es_init_vmcb(struct vcp
        struct kvm_vcpu *vcpu = &svm->vcpu;
  
        svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_SEV_ES_ENABLE;
 -      svm->vmcb->control.virt_ext |= LBR_CTL_ENABLE_MASK;
  
        /*
         * An SEV-ES guest requires a VMSA area that is a separate from the
        /* Clear intercepts on selected MSRs */
        set_msr_interception(vcpu, svm->msrpm, MSR_EFER, 1, 1);
        set_msr_interception(vcpu, svm->msrpm, MSR_IA32_CR_PAT, 1, 1);
 -      set_msr_interception(vcpu, svm->msrpm, MSR_IA32_LASTBRANCHFROMIP, 1, 1);
 -      set_msr_interception(vcpu, svm->msrpm, MSR_IA32_LASTBRANCHTOIP, 1, 1);
 -      set_msr_interception(vcpu, svm->msrpm, MSR_IA32_LASTINTFROMIP, 1, 1);
 -      set_msr_interception(vcpu, svm->msrpm, MSR_IA32_LASTINTTOIP, 1, 1);
  }
  
  void sev_init_vmcb(struct vcpu_svm *svm)
@@@ -4401,9 -4574,9 +4591,9 @@@ void sev_es_prepare_switch_to_guest(str
         * isn't saved by VMRUN, that isn't already saved by VMSAVE (performed
         * by common SVM code).
         */
 -      hostsa->xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK);
 +      hostsa->xcr0 = kvm_host.xcr0;
        hostsa->pkru = read_pkru();
 -      hostsa->xss = host_xss;
 +      hostsa->xss = kvm_host.xss;
  
        /*
         * If DebugSwap is enabled, debug registers are loaded but NOT saved by
@@@ -4459,13 -4632,13 +4649,13 @@@ void sev_vcpu_deliver_sipi_vector(struc
        }
  }
  
 -struct page *snp_safe_alloc_page(struct kvm_vcpu *vcpu)
 +struct page *snp_safe_alloc_page_node(int node, gfp_t gfp)
  {
        unsigned long pfn;
        struct page *p;
  
        if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
 -              return alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 +              return alloc_pages_node(node, gfp | __GFP_ZERO, 0);
  
        /*
         * Allocate an SNP-safe page to workaround the SNP erratum where
         * Allocate one extra page, choose a page which is not
         * 2MB-aligned, and free the other.
         */
 -      p = alloc_pages(GFP_KERNEL_ACCOUNT | __GFP_ZERO, 1);
 +      p = alloc_pages_node(node, gfp | __GFP_ZERO, 1);
        if (!p)
                return NULL;
  
diff --combined arch/x86/kvm/svm/svm.h
index 623426efacc0a295f91bbd383e3c6c3ac5db81d1,8528f40efffc702244cc3e2f6b55432998501060..76107c7d0595d790457209f120d420e99dfc5e15
@@@ -30,7 -30,7 +30,7 @@@
  #define       IOPM_SIZE PAGE_SIZE * 3
  #define       MSRPM_SIZE PAGE_SIZE * 2
  
 -#define MAX_DIRECT_ACCESS_MSRS        47
 +#define MAX_DIRECT_ACCESS_MSRS        48
  #define MSRPM_OFFSETS 32
  extern u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly;
  extern bool npt_enabled;
@@@ -39,7 -39,6 +39,7 @@@ extern int vgif
  extern bool intercept_smi;
  extern bool x2avic_enabled;
  extern bool vnmi;
 +extern int lbrv;
  
  /*
   * Clean bits in VMCB.
@@@ -95,6 -94,9 +95,9 @@@ struct kvm_sev_info 
        struct misc_cg *misc_cg; /* For misc cgroup accounting */
        atomic_t migration_in_progress;
        void *snp_context;      /* SNP guest context page */
+       void *guest_req_buf;    /* Bounce buffer for SNP Guest Request input */
+       void *guest_resp_buf;   /* Bounce buffer for SNP Guest Request output */
+       struct mutex guest_req_mutex; /* Must acquire before using bounce buffers */
  };
  
  struct kvm_svm {
@@@ -583,7 -585,6 +586,7 @@@ u32 *svm_vcpu_alloc_msrpm(void)
  void svm_vcpu_init_msrpm(struct kvm_vcpu *vcpu, u32 *msrpm);
  void svm_vcpu_free_msrpm(u32 *msrpm);
  void svm_copy_lbrs(struct vmcb *to_vmcb, struct vmcb *from_vmcb);
 +void svm_enable_lbrv(struct kvm_vcpu *vcpu);
  void svm_update_lbrv(struct kvm_vcpu *vcpu);
  
  int svm_set_efer(struct kvm_vcpu *vcpu, u64 efer);
@@@ -668,7 -669,7 +671,7 @@@ extern struct kvm_x86_nested_ops svm_ne
  /* avic.c */
  #define AVIC_REQUIRED_APICV_INHIBITS                  \
  (                                                     \
 -      BIT(APICV_INHIBIT_REASON_DISABLE) |             \
 +      BIT(APICV_INHIBIT_REASON_DISABLED) |            \
        BIT(APICV_INHIBIT_REASON_ABSENT) |              \
        BIT(APICV_INHIBIT_REASON_HYPERV) |              \
        BIT(APICV_INHIBIT_REASON_NESTED) |              \
@@@ -726,13 -727,7 +729,13 @@@ void sev_guest_memory_reclaimed(struct 
  int sev_handle_vmgexit(struct kvm_vcpu *vcpu);
  
  /* These symbols are used in common code and are stubbed below.  */
 -struct page *snp_safe_alloc_page(struct kvm_vcpu *vcpu);
 +
 +struct page *snp_safe_alloc_page_node(int node, gfp_t gfp);
 +static inline struct page *snp_safe_alloc_page(void)
 +{
 +      return snp_safe_alloc_page_node(numa_node_id(), GFP_KERNEL_ACCOUNT);
 +}
 +
  void sev_free_vcpu(struct kvm_vcpu *vcpu);
  void sev_vm_destroy(struct kvm *kvm);
  void __init sev_set_cpu_caps(void);
@@@ -747,14 -742,8 +750,14 @@@ int sev_gmem_prepare(struct kvm *kvm, k
  void sev_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end);
  int sev_private_max_mapping_level(struct kvm *kvm, kvm_pfn_t pfn);
  #else
 -static inline struct page *snp_safe_alloc_page(struct kvm_vcpu *vcpu) {
 -      return alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
 +static inline struct page *snp_safe_alloc_page_node(int node, gfp_t gfp)
 +{
 +      return alloc_pages_node(node, gfp | __GFP_ZERO, 0);
 +}
 +
 +static inline struct page *snp_safe_alloc_page(void)
 +{
 +      return snp_safe_alloc_page_node(numa_node_id(), GFP_KERNEL_ACCOUNT);
  }
  
  static inline void sev_free_vcpu(struct kvm_vcpu *vcpu) {}
index 654290a8e1ba31b9ac777f1de90c71fa09c8c852,41e185ad0681d7d5514b403e85f0aff3d73ba328..f0ea26f18cbfd00f538640e48c76288f5f89dda1
@@@ -29,8 -29,6 +29,6 @@@
  #include <asm/svm.h>
  #include <asm/sev.h>
  
- #include "sev-guest.h"
  #define DEVICE_NAME   "sev-guest"
  #define AAD_LEN               48
  #define MSG_HDR_VER   1
@@@ -59,7 -57,7 +57,7 @@@ struct snp_guest_dev 
         */
        struct snp_guest_msg secret_request, secret_response;
  
 -      struct snp_secrets_page_layout *layout;
 +      struct snp_secrets_page *secrets;
        struct snp_req_data input;
        union {
                struct snp_report_req report;
@@@ -743,26 -741,26 +741,26 @@@ static const struct file_operations snp
        .unlocked_ioctl = snp_guest_ioctl,
  };
  
 -static u8 *get_vmpck(int id, struct snp_secrets_page_layout *layout, u32 **seqno)
 +static u8 *get_vmpck(int id, struct snp_secrets_page *secrets, u32 **seqno)
  {
        u8 *key = NULL;
  
        switch (id) {
        case 0:
 -              *seqno = &layout->os_area.msg_seqno_0;
 -              key = layout->vmpck0;
 +              *seqno = &secrets->os_area.msg_seqno_0;
 +              key = secrets->vmpck0;
                break;
        case 1:
 -              *seqno = &layout->os_area.msg_seqno_1;
 -              key = layout->vmpck1;
 +              *seqno = &secrets->os_area.msg_seqno_1;
 +              key = secrets->vmpck1;
                break;
        case 2:
 -              *seqno = &layout->os_area.msg_seqno_2;
 -              key = layout->vmpck2;
 +              *seqno = &secrets->os_area.msg_seqno_2;
 +              key = secrets->vmpck2;
                break;
        case 3:
 -              *seqno = &layout->os_area.msg_seqno_3;
 -              key = layout->vmpck3;
 +              *seqno = &secrets->os_area.msg_seqno_3;
 +              key = secrets->vmpck3;
                break;
        default:
                break;
@@@ -897,8 -895,8 +895,8 @@@ static void unregister_sev_tsm(void *da
  
  static int __init sev_guest_probe(struct platform_device *pdev)
  {
 -      struct snp_secrets_page_layout *layout;
        struct sev_guest_platform_data *data;
 +      struct snp_secrets_page *secrets;
        struct device *dev = &pdev->dev;
        struct snp_guest_dev *snp_dev;
        struct miscdevice *misc;
        if (!mapping)
                return -ENODEV;
  
 -      layout = (__force void *)mapping;
 +      secrets = (__force void *)mapping;
  
        ret = -ENOMEM;
        snp_dev = devm_kzalloc(&pdev->dev, sizeof(struct snp_guest_dev), GFP_KERNEL);
                goto e_unmap;
  
        ret = -EINVAL;
 -      snp_dev->vmpck = get_vmpck(vmpck_id, layout, &snp_dev->os_area_msg_seqno);
 +      snp_dev->vmpck = get_vmpck(vmpck_id, secrets, &snp_dev->os_area_msg_seqno);
        if (!snp_dev->vmpck) {
                dev_err(dev, "invalid vmpck id %d\n", vmpck_id);
                goto e_unmap;
  
        platform_set_drvdata(pdev, snp_dev);
        snp_dev->dev = dev;
 -      snp_dev->layout = layout;
 +      snp_dev->secrets = secrets;
  
        /* Allocate the shared page used for the request and response message. */
        snp_dev->request = alloc_shared_pages(dev, sizeof(struct snp_guest_msg));
This page took 0.225028 seconds and 4 git commands to generate.