From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by mx.groups.io with SMTP id smtpd.web10.2311.1664220777379206677 for ; Mon, 26 Sep 2022 12:32:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@google.com header.s=20210112 header.b=EIjE7XFv; spf=pass (domain: flex--dionnaglaze.bounces.google.com, ip: 209.85.210.202, mailfrom: 3ap4xywskbu0sx322pv0petv33v0t.r31stat0tszh.v63947.x3@flex--dionnaglaze.bounces.google.com) Received: by mail-pf1-f202.google.com with SMTP id u10-20020a056a00098a00b00543b3eb6416so4571780pfg.15 for ; Mon, 26 Sep 2022 12:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date; bh=pz8Fn2Di7Q/3AqXSMc1xXoKE/AJnxMx8BZpYBav1nco=; b=EIjE7XFvZvzZcX4FUbFYJ8NaEifRNLe3SFttMmp5YOjbwYbe0R+pLiM2oo9mhXZVDA BXV0hbiXVeST3wu3pAYCAuVd2jsh+WVqqngS83xn/EMumsEc+eLXiLmT3xgOeDwlM9nB 7hymcmuS3CvwCqOLooevuGpt/b1UPwH6o7zFkGeXzR004Z7KItea8nOjaByqLVDJHLs1 otT4VevpH93A9cQ86vwkLIXpgiTRCbBBfEX8IWap86RoiIBedPvtJRVCtvT0liRvuDTy jc2323+tZ0Z2vby3Pju2rEDbEsqpY+QBhsvgeDPbE8xMH0YZhOVm4ifGAU5BEHLEn2Rf r4FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date; bh=pz8Fn2Di7Q/3AqXSMc1xXoKE/AJnxMx8BZpYBav1nco=; b=uoJ2gcpphpEW0kDHufi5DYSHVw+RWtilicIA6cU6QArNmg/DLh/LAZ1iTL4irwE4RE HwHNJQWb8y7/Jk+Kfdd5qZg5qP0UCH7b+r7JNi72Tlkt6GIqgFqHbgx0OYtxO6xziuhb y56JQGxj6YJt7B1wqBG1QElFAC+iKdNoptQL9vSFBSUl3MuL2e6KvMqcZ8JFiwnOEyvE Uj3dnPopMLYP37C8VRcWeny1INE/hqxY9Lj1/P1AI4dMRFvtkaOcBezcg5Xhkj/VkdWK 1FGiu4oF/AMZsVAjlQx1MQBDEjSILakSwkjwkCzQNNkHN2QUIPOQQm01f4kat2MnUaDO cPpA== X-Gm-Message-State: ACrzQf1DAN5Bw9GxtoxOX5dzcCQ/7w9lGq56gM+Bvf7RZVAG/SibdvIo sVxuIxpjnUi287OOE0oHTtvV7MdF3b/P7z0jm5oSv9JFmuHPe99sZKPH6uR5eBlQsmhEJ3PLklR JA98JRgbwqmiuPqGKXW+PjELPSAhMmLhN3F38J00HYSMO/DWY+7FotTcRQE3CeUEuRfZdxQfa X-Google-Smtp-Source: AMsMyM6FhFSoHAWYHf3i9wNUx6pqThTZWmVzUjJf0B76czEFI+mD2Nl3kMY2+Cj9VB6oPWVvgzfD/Zw7M3bD1bJkFw== X-Received: from dionnaglaze.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2ee6]) (user=dionnaglaze job=sendgmr) by 2002:a17:90a:8986:b0:202:f495:c76f with SMTP id v6-20020a17090a898600b00202f495c76fmr377623pjn.20.1664220776697; Mon, 26 Sep 2022 12:32:56 -0700 (PDT) Date: Mon, 26 Sep 2022 19:32:38 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.37.3.998.g577e59143f-goog Message-ID: <20220926193242.2094502-1-dionnaglaze@google.com> Subject: [PATCH v3 0/4] Add safe unaccepted memory behavior From: "Dionna Glaze" To: devel@edk2.groups.io Cc: Dionna Glaze , Ard Biescheuvel , "Min M. Xu" , Gerd Hoffmann , James Bottomley , Tom Lendacky , Jiewen Yao , Erdem Aktas Content-Type: text/plain; charset="UTF-8" These three patches build on the lazy-accept patch series "Introduce Lazy-accept for Tdx guest" by adding SEV-SNP support for the MemoryAccept protocol, and importantly making eager memory acceptance the default behavior. For unaccepted memory to be enabled, we must know that the booted image supports the unaccepted memory type. We add a trivial protocol that sets a dynamic Pcd to true when called in order for the booted image to signal its support for unaccepted memory. This does not need to be an OsIndications bit because it does not need to be persisted. We use the Pcd to disable a new ExitBootServices notification that accepts all unaccepted memory, removes the unaccepted memory entries in the memory space map, and then add the same memory ranges back as conventional memory. All images that support unaccepted memory must now locate and call this new ENABLE_UNACCEPTED_MEMORY_PROTOCOL. Changes since v2: - Removed the redundant memory accept interface and added the accept behavior to the DXE implementation of MemEncryptSevSnpPreValidateSystemRam. - Fixed missing #include in >=4GB patch. Changes since v1: - Added a patch to classify SEV-SNP memory above 4GB unaccepted. - Fixed style problems in EfiMemoryAcceptProtocol implementation. Cc: Ard Biescheuvel Cc: "Min M. Xu" Cc: Gerd Hoffmann Cc: James Bottomley Cc: Tom Lendacky Cc: Jiewen Yao Cc: Erdem Aktas Signed-off-by: Dionna Glaze Dionna Glaze (4): OvmfPkg: Realize EfiMemoryAcceptProtocol in AmdSevDxe DxeMain accepts all memory at EBS if needed MdeModulePkg: add EnableUnacceptedMemoryProtocol OvmfPkg/PlatformPei: SEV-SNP make >=4GB unaccepted MdeModulePkg/Core/Dxe/DxeMain.h | 32 +++++ MdeModulePkg/Core/Dxe/DxeMain.inf | 3 + MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 19 ++- MdeModulePkg/Core/Dxe/Mem/Page.c | 122 ++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 9 ++ MdeModulePkg/MdeModulePkg.uni | 6 + OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/AmdSevDxe/AmdSevDxe.c | 34 ++++++ OvmfPkg/AmdSevDxe/AmdSevDxe.inf | 3 + OvmfPkg/Bhyve/BhyveX64.dsc | 2 + OvmfPkg/CloudHv/CloudHvX64.dsc | 2 + OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 + OvmfPkg/Library/BaseMemEncryptSevLib/X64/DxeSnpSystemRamValidate.c | 24 +++- OvmfPkg/OvmfPkgIa32X64.dsc | 2 + OvmfPkg/OvmfPkgX64.dsc | 2 + OvmfPkg/OvmfXen.dsc | 2 + OvmfPkg/PlatformPei/AmdSev.c | 5 + 17 files changed, 265 insertions(+), 5 deletions(-) -- 2.37.3.998.g577e59143f-goog