Skip to content

Commit f3c8006

Browse files
committed
KVM: SEV: fix compat ABI for KVM_MEMORY_ENCRYPT_OP
The data structs for KVM_MEMORY_ENCRYPT_OP have different sizes for 32- and 64-bit userspace, but they do not make any attempt to convert from one ABI to the other when 32-bit userspace is running on 64-bit kernels. This configuration never worked, and SEV is only for 64-bit kernels so we're not breaking ABI on 32-bit kernels. Fix this by adding the appropriate padding; no functional change intended for 64-bit userspace. Reviewed-by: Michael Roth <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c822a07 commit f3c8006

File tree

1 file changed

+23
-0
lines changed
  • arch/x86/include/uapi/asm

1 file changed

+23
-0
lines changed

arch/x86/include/uapi/asm/kvm.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ enum sev_cmd_id {
694694

695695
struct kvm_sev_cmd {
696696
__u32 id;
697+
__u32 pad0;
697698
__u64 data;
698699
__u32 error;
699700
__u32 sev_fd;
@@ -704,28 +705,35 @@ struct kvm_sev_launch_start {
704705
__u32 policy;
705706
__u64 dh_uaddr;
706707
__u32 dh_len;
708+
__u32 pad0;
707709
__u64 session_uaddr;
708710
__u32 session_len;
711+
__u32 pad1;
709712
};
710713

711714
struct kvm_sev_launch_update_data {
712715
__u64 uaddr;
713716
__u32 len;
717+
__u32 pad0;
714718
};
715719

716720

717721
struct kvm_sev_launch_secret {
718722
__u64 hdr_uaddr;
719723
__u32 hdr_len;
724+
__u32 pad0;
720725
__u64 guest_uaddr;
721726
__u32 guest_len;
727+
__u32 pad1;
722728
__u64 trans_uaddr;
723729
__u32 trans_len;
730+
__u32 pad2;
724731
};
725732

726733
struct kvm_sev_launch_measure {
727734
__u64 uaddr;
728735
__u32 len;
736+
__u32 pad0;
729737
};
730738

731739
struct kvm_sev_guest_status {
@@ -738,51 +746,66 @@ struct kvm_sev_dbg {
738746
__u64 src_uaddr;
739747
__u64 dst_uaddr;
740748
__u32 len;
749+
__u32 pad0;
741750
};
742751

743752
struct kvm_sev_attestation_report {
744753
__u8 mnonce[16];
745754
__u64 uaddr;
746755
__u32 len;
756+
__u32 pad0;
747757
};
748758

749759
struct kvm_sev_send_start {
750760
__u32 policy;
761+
__u32 pad0;
751762
__u64 pdh_cert_uaddr;
752763
__u32 pdh_cert_len;
764+
__u32 pad1;
753765
__u64 plat_certs_uaddr;
754766
__u32 plat_certs_len;
767+
__u32 pad2;
755768
__u64 amd_certs_uaddr;
756769
__u32 amd_certs_len;
770+
__u32 pad3;
757771
__u64 session_uaddr;
758772
__u32 session_len;
773+
__u32 pad4;
759774
};
760775

761776
struct kvm_sev_send_update_data {
762777
__u64 hdr_uaddr;
763778
__u32 hdr_len;
779+
__u32 pad0;
764780
__u64 guest_uaddr;
765781
__u32 guest_len;
782+
__u32 pad1;
766783
__u64 trans_uaddr;
767784
__u32 trans_len;
785+
__u32 pad2;
768786
};
769787

770788
struct kvm_sev_receive_start {
771789
__u32 handle;
772790
__u32 policy;
773791
__u64 pdh_uaddr;
774792
__u32 pdh_len;
793+
__u32 pad0;
775794
__u64 session_uaddr;
776795
__u32 session_len;
796+
__u32 pad1;
777797
};
778798

779799
struct kvm_sev_receive_update_data {
780800
__u64 hdr_uaddr;
781801
__u32 hdr_len;
802+
__u32 pad0;
782803
__u64 guest_uaddr;
783804
__u32 guest_len;
805+
__u32 pad1;
784806
__u64 trans_uaddr;
785807
__u32 trans_len;
808+
__u32 pad2;
786809
};
787810

788811
#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)

0 commit comments

Comments
 (0)