mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] x86/mm: fix pg_level_to_pfn for 5-level paging mode.
@ 2023-10-18 19:06 Ashish Kalra
  2023-10-18 20:30 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Ashish Kalra @ 2023-10-18 19:06 UTC (permalink / raw)
  To: dave.hansen, luto, tglx, mingo, bp, x86, hpa, thomas.lendacky,
	linux-kernel, peterz

From: Ashish Kalra <ashish.kalra@amd.com>

Add support for 5-level paging in pg_level_to_pfn().

This issue was found during working on SNP guest kexec support,
this helper function is used during early boot stage for setting
of C-bit on the PTEs and additionally need this same helper for
switching shared pages to private during guest kexec.

Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
 arch/x86/mm/mem_encrypt_amd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/mm/mem_encrypt_amd.c b/arch/x86/mm/mem_encrypt_amd.c
index 6faea41e99b6..45914568596a 100644
--- a/arch/x86/mm/mem_encrypt_amd.c
+++ b/arch/x86/mm/mem_encrypt_amd.c
@@ -267,6 +267,10 @@ static unsigned long pg_level_to_pfn(int level, pte_t *kpte, pgprot_t *ret_prot)
 		pfn = pud_pfn(*(pud_t *)kpte);
 		prot = pud_pgprot(*(pud_t *)kpte);
 		break;
+	case PG_LEVEL_512G:
+		pfn = p4d_pfn(*(p4d_t *)kpte);
+		prot = p4d_pgprot(*(p4d_t *)kpte);
+		break;
 	default:
 		WARN_ONCE(1, "Invalid level for kpte\n");
 		return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86/mm: fix pg_level_to_pfn for 5-level paging mode.
  2023-10-18 19:06 [PATCH v2] x86/mm: fix pg_level_to_pfn for 5-level paging mode Ashish Kalra
@ 2023-10-18 20:30 ` Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2023-10-18 20:30 UTC (permalink / raw)
  To: Ashish Kalra
  Cc: dave.hansen, luto, tglx, mingo, x86, hpa, thomas.lendacky,
	linux-kernel, peterz

On Wed, Oct 18, 2023 at 07:06:26PM +0000, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
> 
> Add support for 5-level paging in pg_level_to_pfn().
> 
> This issue was found during working on SNP guest kexec support,
> this helper function is used during early boot stage for setting
> of C-bit on the PTEs and additionally need this same helper for
> switching shared pages to private during guest kexec.

How to write a proper commit message:

1. Prepare the context for the explanation briefly.

2. Explain the problem at hand.

3. "It happens because of <...>"

4. "Fix it by doing X"

5. "(Potentially do Y)."

For more detailed info, see
Documentation/process/submitting-patches.rst, Section "2) Describe your
changes".

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-18 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 19:06 [PATCH v2] x86/mm: fix pg_level_to_pfn for 5-level paging mode Ashish Kalra
2023-10-18 20:30 ` Borislav Petkov

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®