* [PATCH] x86/mm: Limit INVLPGB to VA in invlpgb_flush_addr_nosync()
@ 2025-05-27 21:56 Jann Horn
2025-05-27 23:39 ` Rik van Riel
0 siblings, 1 reply; 2+ messages in thread
From: Jann Horn @ 2025-05-27 21:56 UTC (permalink / raw)
To: Rik van Riel, Borislav Petkov, Ingo Molnar, Dave Hansen,
Andy Lutomirski, Peter Zijlstra
Cc: linux-kernel, Jann Horn
The intent of invlpgb_flush_addr_nosync() is to flush a specific virtual
address range, but INVLPGB_FLAG_VA is not set.
If I understand AMD's documentation correctly, this means this will flush
the entire TLB (except entries for guest ASIDs).
That's safe, but seems like an unintentionally broad flush.
Fix it by setting INVLPGB_FLAG_VA.
Fixes: b7aa05cbdc52 ("x86/mm: Add INVLPGB support code")
Signed-off-by: Jann Horn <jannh@google.com>
---
I am not entirely sure about this; Rik, can you confirm if this was an
oversight, or if there's actually a reason for not passing
INVLPGB_FLAG_VA here?
I feel a bit uncomfortable touching TLB flushing and narrowing a flush
there...
---
arch/x86/include/asm/tlb.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
index 866ea78ba156..e257201a141a 100644
--- a/arch/x86/include/asm/tlb.h
+++ b/arch/x86/include/asm/tlb.h
@@ -153,7 +153,8 @@ static inline void invlpgb_flush_all(void)
/* Flush addr, including globals, for all PCIDs. */
static inline void invlpgb_flush_addr_nosync(unsigned long addr, u16 nr)
{
- __invlpgb(0, 0, addr, nr, PTE_STRIDE, INVLPGB_FLAG_INCLUDE_GLOBAL);
+ __invlpgb(0, 0, addr, nr, PTE_STRIDE,
+ INVLPGB_FLAG_VA | INVLPGB_FLAG_INCLUDE_GLOBAL);
}
/* Flush all mappings for all PCIDs except globals. */
---
base-commit: b1456f6dc167f7f101746e495bede2bac3d0e19f
change-id: 20250527-x86-overbroad-invlpgb-34f903c9e2b3
--
Jann Horn <jannh@google.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] x86/mm: Limit INVLPGB to VA in invlpgb_flush_addr_nosync()
2025-05-27 21:56 [PATCH] x86/mm: Limit INVLPGB to VA in invlpgb_flush_addr_nosync() Jann Horn
@ 2025-05-27 23:39 ` Rik van Riel
0 siblings, 0 replies; 2+ messages in thread
From: Rik van Riel @ 2025-05-27 23:39 UTC (permalink / raw)
To: Jann Horn, Borislav Petkov, Ingo Molnar, Dave Hansen,
Andy Lutomirski, Peter Zijlstra
Cc: linux-kernel
On Tue, 2025-05-27 at 23:56 +0200, Jann Horn wrote:
> The intent of invlpgb_flush_addr_nosync() is to flush a specific
> virtual
> address range, but INVLPGB_FLAG_VA is not set.
> If I understand AMD's documentation correctly, this means this will
> flush
> the entire TLB (except entries for guest ASIDs).
> That's safe, but seems like an unintentionally broad flush.
> Fix it by setting INVLPGB_FLAG_VA.
>
> Fixes: b7aa05cbdc52 ("x86/mm: Add INVLPGB support code")
> Signed-off-by: Jann Horn <jannh@google.com>
Reviewed-by: Rik van Riel <riel@surriel.com>
> ---
> I am not entirely sure about this; Rik, can you confirm if this was
> an
> oversight, or if there's actually a reason for not passing
> INVLPGB_FLAG_VA here?
This was totally an oversight, and probably lost
in one of many rounds of cleanups.
Good catch!
--
All Rights Reversed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-27 23:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-27 21:56 [PATCH] x86/mm: Limit INVLPGB to VA in invlpgb_flush_addr_nosync() Jann Horn
2025-05-27 23:39 ` Rik van Riel
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®