Index | Thread | Search

From:
Hans-Jörg Höxer <hshoexer@genua.de>
Subject:
SEV-SNP: Claim pages early 3/4
To:
<tech@openbsd.org>
Date:
Tue, 11 Aug 2026 11:36:12 +0200

Download raw body.

Thread
  • Hans-Jörg Höxer:

    SEV-SNP: Claim pages early 3/4

Hi,

this is diff 3/4 for SEV-SNP guest support.

When initially loading UVM claim all pages from the hypervisor.
However, as a firmware might already has pvalidated these pages,
it is ok when page state does not change.

But from then on, page state must change when rescinding and claiming
pages.

ok? comments?

Take care,
HJ.

---
 sys/arch/amd64/amd64/machdep.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index bbf1e415962..ad44bea3162 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -102,6 +102,7 @@
 #include <machine/tss.h>
 #include <machine/ghcb.h>
 #include <machine/kexec.h>
+#include <machine/snp.h>
 
 #include <dev/isa/isareg.h>
 #include <dev/ic/i8042reg.h>
@@ -1730,6 +1731,7 @@ init_x86_64(paddr_t first_avail)
 #endif
 		uvm_page_physload(atop(seg_start), atop(seg_end),
 		    atop(seg_start), atop(seg_end), 0);
+		snp_claim_early(seg_start, seg_end);
 	}
 
 	/*
@@ -1746,9 +1748,13 @@ init_x86_64(paddr_t first_avail)
 #endif
 			uvm_page_physload(atop(seg_start), atop(seg_end),
 			    atop(seg_start), atop(seg_end), 0);
+			snp_claim_early(seg_start, seg_end);
 		}
 	}
 
+	/* SEV-SNP: Claim ISA hole. */
+	snp_claim_early(IOM_BEGIN, IOM_END);
+
 #if DEBUG_MEMLOAD
 	printf("avail_start = 0x%lx\n", avail_start);
 	printf("avail_end = 0x%lx\n", avail_end);
-- 
2.53.0