From: Borislav Petkov <bp@alien8.de>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Michael Roth <michael.roth@amd.com>,
Ashish Kalra <ashish.kalra@amd.com>,
Nikunj A Dadhania <nikunj@amd.com>,
Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Subject: Re: [PATCH v6 1/8] x86/sev: Prepare for using the RMPREAD instruction to access the RMP
Date: Tue, 3 Dec 2024 17:01:46 +0100 [thread overview]
Message-ID: <20241203160146.GDZ08rahZMYc3vyoxq@fat_crate.local> (raw)
In-Reply-To: <da49d5af1eb7f9039f35f14a32ca091efb2dd818.1733172653.git.thomas.lendacky@amd.com>
On Mon, Dec 02, 2024 at 02:50:46PM -0600, Tom Lendacky wrote:
> +static int __snp_lookup_rmpentry(u64 pfn, struct rmpentry *e, int *level)
> +{
> + struct rmpentry e_large;
> + int ret;
> +
> + if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
Btw, just a side note: this is AMD-specific and x86 code so we probably should
use:
if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP))
For another series.
> + return -ENODEV;
> +
> + ret = get_rmpentry(pfn, e);
> + if (ret)
> + return ret;
>
> /*
> * Find the authoritative RMP entry for a PFN. This can be either a 4K
> * RMP entry or a special large RMP entry that is authoritative for a
> * whole 2M area.
> */
> - large_entry = get_rmpentry(pfn & PFN_PMD_MASK);
> - if (IS_ERR(large_entry))
> - return large_entry;
> + ret = get_rmpentry(pfn & PFN_PMD_MASK, &e_large);
> + if (ret)
> + return ret;
>
> - *level = RMP_TO_PG_LEVEL(large_entry->pagesize);
> + *level = RMP_TO_PG_LEVEL(e_large.pagesize);
>
> - return entry;
> + return 0;
> }
...
> static void dump_rmpentry(u64 pfn)
> {
> + struct rmpentry_raw *e_raw;
> u64 pfn_i, pfn_end;
> - struct rmpentry *e;
> - int level;
> + struct rmpentry e;
> + int level, ret;
>
> - e = __snp_lookup_rmpentry(pfn, &level);
> - if (IS_ERR(e)) {
> - pr_err("Failed to read RMP entry for PFN 0x%llx, error %ld\n",
> - pfn, PTR_ERR(e));
> + ret = __snp_lookup_rmpentry(pfn, &e, &level);
> + if (ret) {
> + pr_err("Failed to read RMP entry for PFN 0x%llx, error %d\n",
> + pfn, ret);
> return;
> }
>
> - if (e->assigned) {
> + if (e.assigned) {
> + e_raw = get_raw_rmpentry(pfn);
> + if (IS_ERR(e_raw)) {
> + pr_err("Failed to read RMP contents for PFN 0x%llx, error %ld\n",
> + pfn, PTR_ERR(e_raw));
> + return;
> + }
> +
> pr_info("PFN 0x%llx, RMP entry: [0x%016llx - 0x%016llx]\n",
> - pfn, e->lo, e->hi);
> + pfn, e_raw->lo, e_raw->hi);
> return;
> }
Do I see it correctly that we don't really need to call that
get_raw_rmpentry() again for that @pfn because __snp_lookup_rmpentry()
returned the whole thing in @e already?
IOW:
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index cf64e9384ea0..2e1833426b08 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -387,15 +387,8 @@ static void dump_rmpentry(u64 pfn)
}
if (e.assigned) {
- e_raw = get_raw_rmpentry(pfn);
- if (IS_ERR(e_raw)) {
- pr_err("Failed to read RMP contents for PFN 0x%llx, error %ld\n",
- pfn, PTR_ERR(e_raw));
- return;
- }
-
- pr_info("PFN 0x%llx, RMP entry: [0x%016llx - 0x%016llx]\n",
- pfn, e_raw->lo, e_raw->hi);
+ pr_info("PFN 0x%llx, RMP entry: [ASID: 0x%x, pagesize: 0x%x, immutable: %d]\n",
+ e.gpa, e.asid, e.pagesize, e.immutable);
return;
}
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2024-12-03 16:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 20:50 [PATCH v6 0/8] Provide support for RMPREAD and a segmented RMP Tom Lendacky
2024-12-02 20:50 ` [PATCH v6 1/8] x86/sev: Prepare for using the RMPREAD instruction to access the RMP Tom Lendacky
2024-12-03 16:01 ` Borislav Petkov [this message]
2024-12-03 16:08 ` Tom Lendacky
2024-12-03 20:56 ` Borislav Petkov
2024-12-02 20:50 ` [PATCH v6 2/8] x86/sev: Add support for the RMPREAD instruction Tom Lendacky
2024-12-02 20:50 ` [PATCH v6 3/8] x86/sev: Require the RMPREAD instruction after Zen4 Tom Lendacky
2024-12-02 20:50 ` [PATCH v6 4/8] x86/sev: Move the SNP probe routine out of the way Tom Lendacky
2024-12-02 20:50 ` [PATCH v6 5/8] x86/sev: Map only the RMP table entries instead of the full RMP range Tom Lendacky
2024-12-02 20:50 ` [PATCH v6 6/8] x86/sev: Treat the contiguous RMP table as a single RMP segment Tom Lendacky
2024-12-09 19:43 ` Borislav Petkov
2024-12-10 10:28 ` Borislav Petkov
2024-12-10 10:48 ` Borislav Petkov
2024-12-10 14:36 ` Tom Lendacky
2024-12-02 20:50 ` [PATCH v6 7/8] x86/sev: Add full support for a segmented RMP table Tom Lendacky
2024-12-12 9:11 ` Borislav Petkov
2024-12-12 14:46 ` Tom Lendacky
2024-12-12 15:41 ` Borislav Petkov
2024-12-13 14:55 ` [PATCH v6.1 " Tom Lendacky
2024-12-02 20:50 ` [PATCH v6 8/8] x86/sev/docs: Document the SNP Reverse Map Table (RMP) Tom Lendacky
2024-12-16 14:21 ` [PATCH v6 0/8] Provide support for RMPREAD and a segmented RMP Tom Lendacky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241203160146.GDZ08rahZMYc3vyoxq@fat_crate.local \
--to=bp@alien8.de \
--cc=Neeraj.Upadhyay@amd.com \
--cc=ashish.kalra@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=nikunj@amd.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®