@@ -78,6 +78,36 @@ enum sev_cmd {
78
78
SEV_CMD_DBG_DECRYPT = 0x060 ,
79
79
SEV_CMD_DBG_ENCRYPT = 0x061 ,
80
80
81
+ /* SNP specific commands */
82
+ SEV_CMD_SNP_INIT = 0x081 ,
83
+ SEV_CMD_SNP_SHUTDOWN = 0x082 ,
84
+ SEV_CMD_SNP_PLATFORM_STATUS = 0x083 ,
85
+ SEV_CMD_SNP_DF_FLUSH = 0x084 ,
86
+ SEV_CMD_SNP_INIT_EX = 0x085 ,
87
+ SEV_CMD_SNP_SHUTDOWN_EX = 0x086 ,
88
+ SEV_CMD_SNP_DECOMMISSION = 0x090 ,
89
+ SEV_CMD_SNP_ACTIVATE = 0x091 ,
90
+ SEV_CMD_SNP_GUEST_STATUS = 0x092 ,
91
+ SEV_CMD_SNP_GCTX_CREATE = 0x093 ,
92
+ SEV_CMD_SNP_GUEST_REQUEST = 0x094 ,
93
+ SEV_CMD_SNP_ACTIVATE_EX = 0x095 ,
94
+ SEV_CMD_SNP_LAUNCH_START = 0x0A0 ,
95
+ SEV_CMD_SNP_LAUNCH_UPDATE = 0x0A1 ,
96
+ SEV_CMD_SNP_LAUNCH_FINISH = 0x0A2 ,
97
+ SEV_CMD_SNP_DBG_DECRYPT = 0x0B0 ,
98
+ SEV_CMD_SNP_DBG_ENCRYPT = 0x0B1 ,
99
+ SEV_CMD_SNP_PAGE_SWAP_OUT = 0x0C0 ,
100
+ SEV_CMD_SNP_PAGE_SWAP_IN = 0x0C1 ,
101
+ SEV_CMD_SNP_PAGE_MOVE = 0x0C2 ,
102
+ SEV_CMD_SNP_PAGE_MD_INIT = 0x0C3 ,
103
+ SEV_CMD_SNP_PAGE_SET_STATE = 0x0C6 ,
104
+ SEV_CMD_SNP_PAGE_RECLAIM = 0x0C7 ,
105
+ SEV_CMD_SNP_PAGE_UNSMASH = 0x0C8 ,
106
+ SEV_CMD_SNP_CONFIG = 0x0C9 ,
107
+ SEV_CMD_SNP_DOWNLOAD_FIRMWARE_EX = 0x0CA ,
108
+ SEV_CMD_SNP_COMMIT = 0x0CB ,
109
+ SEV_CMD_SNP_VLEK_LOAD = 0x0CD ,
110
+
81
111
SEV_CMD_MAX ,
82
112
};
83
113
@@ -523,6 +553,241 @@ struct sev_data_attestation_report {
523
553
u32 len ; /* In/Out */
524
554
} __packed ;
525
555
556
+ /**
557
+ * struct sev_data_snp_download_firmware - SNP_DOWNLOAD_FIRMWARE command params
558
+ *
559
+ * @address: physical address of firmware image
560
+ * @len: length of the firmware image
561
+ */
562
+ struct sev_data_snp_download_firmware {
563
+ u64 address ; /* In */
564
+ u32 len ; /* In */
565
+ } __packed ;
566
+
567
+ /**
568
+ * struct sev_data_snp_activate - SNP_ACTIVATE command params
569
+ *
570
+ * @gctx_paddr: system physical address guest context page
571
+ * @asid: ASID to bind to the guest
572
+ */
573
+ struct sev_data_snp_activate {
574
+ u64 gctx_paddr ; /* In */
575
+ u32 asid ; /* In */
576
+ } __packed ;
577
+
578
+ /**
579
+ * struct sev_data_snp_addr - generic SNP command params
580
+ *
581
+ * @address: physical address of generic data param
582
+ */
583
+ struct sev_data_snp_addr {
584
+ u64 address ; /* In/Out */
585
+ } __packed ;
586
+
587
+ /**
588
+ * struct sev_data_snp_launch_start - SNP_LAUNCH_START command params
589
+ *
590
+ * @gctx_paddr: system physical address of guest context page
591
+ * @policy: guest policy
592
+ * @ma_gctx_paddr: system physical address of migration agent
593
+ * @ma_en: the guest is associated with a migration agent
594
+ * @imi_en: launch flow is launching an IMI (Incoming Migration Image) for the
595
+ * purpose of guest-assisted migration.
596
+ * @rsvd: reserved
597
+ * @gosvw: guest OS-visible workarounds, as defined by hypervisor
598
+ */
599
+ struct sev_data_snp_launch_start {
600
+ u64 gctx_paddr ; /* In */
601
+ u64 policy ; /* In */
602
+ u64 ma_gctx_paddr ; /* In */
603
+ u32 ma_en :1 ; /* In */
604
+ u32 imi_en :1 ; /* In */
605
+ u32 rsvd :30 ;
606
+ u8 gosvw [16 ]; /* In */
607
+ } __packed ;
608
+
609
+ /* SNP support page type */
610
+ enum {
611
+ SNP_PAGE_TYPE_NORMAL = 0x1 ,
612
+ SNP_PAGE_TYPE_VMSA = 0x2 ,
613
+ SNP_PAGE_TYPE_ZERO = 0x3 ,
614
+ SNP_PAGE_TYPE_UNMEASURED = 0x4 ,
615
+ SNP_PAGE_TYPE_SECRET = 0x5 ,
616
+ SNP_PAGE_TYPE_CPUID = 0x6 ,
617
+
618
+ SNP_PAGE_TYPE_MAX
619
+ };
620
+
621
+ /**
622
+ * struct sev_data_snp_launch_update - SNP_LAUNCH_UPDATE command params
623
+ *
624
+ * @gctx_paddr: system physical address of guest context page
625
+ * @page_size: page size 0 indicates 4K and 1 indicates 2MB page
626
+ * @page_type: encoded page type
627
+ * @imi_page: indicates that this page is part of the IMI (Incoming Migration
628
+ * Image) of the guest
629
+ * @rsvd: reserved
630
+ * @rsvd2: reserved
631
+ * @address: system physical address of destination page to encrypt
632
+ * @rsvd3: reserved
633
+ * @vmpl1_perms: VMPL permission mask for VMPL1
634
+ * @vmpl2_perms: VMPL permission mask for VMPL2
635
+ * @vmpl3_perms: VMPL permission mask for VMPL3
636
+ * @rsvd4: reserved
637
+ */
638
+ struct sev_data_snp_launch_update {
639
+ u64 gctx_paddr ; /* In */
640
+ u32 page_size :1 ; /* In */
641
+ u32 page_type :3 ; /* In */
642
+ u32 imi_page :1 ; /* In */
643
+ u32 rsvd :27 ;
644
+ u32 rsvd2 ;
645
+ u64 address ; /* In */
646
+ u32 rsvd3 :8 ;
647
+ u32 vmpl1_perms :8 ; /* In */
648
+ u32 vmpl2_perms :8 ; /* In */
649
+ u32 vmpl3_perms :8 ; /* In */
650
+ u32 rsvd4 ;
651
+ } __packed ;
652
+
653
+ /**
654
+ * struct sev_data_snp_launch_finish - SNP_LAUNCH_FINISH command params
655
+ *
656
+ * @gctx_paddr: system physical address of guest context page
657
+ * @id_block_paddr: system physical address of ID block
658
+ * @id_auth_paddr: system physical address of ID block authentication structure
659
+ * @id_block_en: indicates whether ID block is present
660
+ * @auth_key_en: indicates whether author key is present in authentication structure
661
+ * @rsvd: reserved
662
+ * @host_data: host-supplied data for guest, not interpreted by firmware
663
+ */
664
+ struct sev_data_snp_launch_finish {
665
+ u64 gctx_paddr ;
666
+ u64 id_block_paddr ;
667
+ u64 id_auth_paddr ;
668
+ u8 id_block_en :1 ;
669
+ u8 auth_key_en :1 ;
670
+ u64 rsvd :62 ;
671
+ u8 host_data [32 ];
672
+ } __packed ;
673
+
674
+ /**
675
+ * struct sev_data_snp_guest_status - SNP_GUEST_STATUS command params
676
+ *
677
+ * @gctx_paddr: system physical address of guest context page
678
+ * @address: system physical address of guest status page
679
+ */
680
+ struct sev_data_snp_guest_status {
681
+ u64 gctx_paddr ;
682
+ u64 address ;
683
+ } __packed ;
684
+
685
+ /**
686
+ * struct sev_data_snp_page_reclaim - SNP_PAGE_RECLAIM command params
687
+ *
688
+ * @paddr: system physical address of page to be claimed. The 0th bit in the
689
+ * address indicates the page size. 0h indicates 4KB and 1h indicates
690
+ * 2MB page.
691
+ */
692
+ struct sev_data_snp_page_reclaim {
693
+ u64 paddr ;
694
+ } __packed ;
695
+
696
+ /**
697
+ * struct sev_data_snp_page_unsmash - SNP_PAGE_UNSMASH command params
698
+ *
699
+ * @paddr: system physical address of page to be unsmashed. The 0th bit in the
700
+ * address indicates the page size. 0h indicates 4 KB and 1h indicates
701
+ * 2 MB page.
702
+ */
703
+ struct sev_data_snp_page_unsmash {
704
+ u64 paddr ;
705
+ } __packed ;
706
+
707
+ /**
708
+ * struct sev_data_snp_dbg - DBG_ENCRYPT/DBG_DECRYPT command parameters
709
+ *
710
+ * @gctx_paddr: system physical address of guest context page
711
+ * @src_addr: source address of data to operate on
712
+ * @dst_addr: destination address of data to operate on
713
+ */
714
+ struct sev_data_snp_dbg {
715
+ u64 gctx_paddr ; /* In */
716
+ u64 src_addr ; /* In */
717
+ u64 dst_addr ; /* In */
718
+ } __packed ;
719
+
720
+ /**
721
+ * struct sev_data_snp_guest_request - SNP_GUEST_REQUEST command params
722
+ *
723
+ * @gctx_paddr: system physical address of guest context page
724
+ * @req_paddr: system physical address of request page
725
+ * @res_paddr: system physical address of response page
726
+ */
727
+ struct sev_data_snp_guest_request {
728
+ u64 gctx_paddr ; /* In */
729
+ u64 req_paddr ; /* In */
730
+ u64 res_paddr ; /* In */
731
+ } __packed ;
732
+
733
+ /**
734
+ * struct sev_data_snp_init_ex - SNP_INIT_EX structure
735
+ *
736
+ * @init_rmp: indicate that the RMP should be initialized.
737
+ * @list_paddr_en: indicate that list_paddr is valid
738
+ * @rsvd: reserved
739
+ * @rsvd1: reserved
740
+ * @list_paddr: system physical address of range list
741
+ * @rsvd2: reserved
742
+ */
743
+ struct sev_data_snp_init_ex {
744
+ u32 init_rmp :1 ;
745
+ u32 list_paddr_en :1 ;
746
+ u32 rsvd :30 ;
747
+ u32 rsvd1 ;
748
+ u64 list_paddr ;
749
+ u8 rsvd2 [48 ];
750
+ } __packed ;
751
+
752
+ /**
753
+ * struct sev_data_range - RANGE structure
754
+ *
755
+ * @base: system physical address of first byte of range
756
+ * @page_count: number of 4KB pages in this range
757
+ * @rsvd: reserved
758
+ */
759
+ struct sev_data_range {
760
+ u64 base ;
761
+ u32 page_count ;
762
+ u32 rsvd ;
763
+ } __packed ;
764
+
765
+ /**
766
+ * struct sev_data_range_list - RANGE_LIST structure
767
+ *
768
+ * @num_elements: number of elements in RANGE_ARRAY
769
+ * @rsvd: reserved
770
+ * @ranges: array of num_elements of type RANGE
771
+ */
772
+ struct sev_data_range_list {
773
+ u32 num_elements ;
774
+ u32 rsvd ;
775
+ struct sev_data_range ranges [];
776
+ } __packed ;
777
+
778
+ /**
779
+ * struct sev_data_snp_shutdown_ex - SNP_SHUTDOWN_EX structure
780
+ *
781
+ * @len: length of the command buffer read by the PSP
782
+ * @iommu_snp_shutdown: Disable enforcement of SNP in the IOMMU
783
+ * @rsvd1: reserved
784
+ */
785
+ struct sev_data_snp_shutdown_ex {
786
+ u32 len ;
787
+ u32 iommu_snp_shutdown :1 ;
788
+ u32 rsvd1 :31 ;
789
+ } __packed ;
790
+
526
791
#ifdef CONFIG_CRYPTO_DEV_SP_PSP
527
792
528
793
/**
0 commit comments