Message ID | 20240712-asi-rfc-24-v1-9-144b319a40d8@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1E0C2BD09 for <linux-mm@archiver.kernel.org>; Fri, 12 Jul 2024 17:01:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A33E6B00A0; Fri, 12 Jul 2024 13:01:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62C736B00A1; Fri, 12 Jul 2024 13:01:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42FB56B00A2; Fri, 12 Jul 2024 13:01:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1487D6B00A0 for <linux-mm@kvack.org>; Fri, 12 Jul 2024 13:01:22 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7276E140787 for <linux-mm@kvack.org>; Fri, 12 Jul 2024 17:01:21 +0000 (UTC) X-FDA: 82331716362.06.65EE14D Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf03.hostedemail.com (Postfix) with ESMTP id ED78920033 for <linux-mm@kvack.org>; Fri, 12 Jul 2024 17:01:18 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SJvoR4yd; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3XWGRZggKCKAJACKMANBGOOGLE.COMLINUX-MMKVACK.ORG@flex--jackmanb.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=3XWGRZggKCKAJACKMANBGOOGLE.COMLINUX-MMKVACK.ORG@flex--jackmanb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720803653; a=rsa-sha256; cv=none; b=nhGuGgFd3UC9V9Fzyxt2sh+1KEoaQre4jhe0tajg6dfIcWauAA0YdG6EvrqX1VzoS7Hxh8 V9CrgfGc7XPZdaOv8n6F8iCHi9jgShRalheXGFLkjwuDhhqJ53DjPmg7sHHjE3If4VqR+X S3XJOYzZkTQoUlRYV6+gp8Nk2CXMTqM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SJvoR4yd; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of 3XWGRZggKCKAJACKMANBGOOGLE.COMLINUX-MMKVACK.ORG@flex--jackmanb.bounces.google.com designates 209.85.128.74 as permitted sender) smtp.mailfrom=3XWGRZggKCKAJACKMANBGOOGLE.COMLINUX-MMKVACK.ORG@flex--jackmanb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720803653; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=STKCp8fX1eTmkj5Bbc4ElFS0AmmAwYWDzWQm15HV9Io=; b=Kvhhx2Gfzof39zjYt1Wdg0G6hKyI7+LjVHSiZz9K6ytB7WoMf/S90NMi3Orl9lFTb3sfUp ZeBJ3ogRReHyirtkvfGlvnYMwUcJIfHP7SkJIGqMqs6wc9hY5/Y7xXyAuMqmI0X7bXXJh2 CWDXPkNn9Y3cFwHtfX3iGoyArqyWhsc= Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4272718b9b0so14630545e9.1 for <linux-mm@kvack.org>; Fri, 12 Jul 2024 10:01:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720803677; x=1721408477; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=STKCp8fX1eTmkj5Bbc4ElFS0AmmAwYWDzWQm15HV9Io=; b=SJvoR4ydmpHToPGYiENBBydKQIrUsYHIOHV2AkjK6Kvze9geU/ZU0aJmRwDeZdMqjK iX2RtvzuhWlQlpGmiZ27DHAJwaHE/2q7K3TD4wmDUxMBkEoUiBidiGZNnDtweKWoWLTr TvfTI/8daH9m2Umy2iMjiQQUzZS3nu8N3FxfpPu5+p16qmXk3HR4SzrgxKRjbQpcPJpM ZeGnzJZ5kBdFFWf8n2bexTvV79T8wvEm9wHrQmJQPO42aQGNrzUrXOA0HD9A0R6za+Aj Cp0VBjQEg47deP0IBbW0lPTQqK6cHwcmgVWLGx9hpf3yu+ElMRbiaLbYfYc7WFaLvA2H V6kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720803677; x=1721408477; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=STKCp8fX1eTmkj5Bbc4ElFS0AmmAwYWDzWQm15HV9Io=; b=WaFX4CFKg74qxSUq66vuuIKqGR8i8Dr6jir40ssKzU2wrwdfBkePrJ8Z2kMSdDVkz4 4f7a2aKtsExn1vdEq5paVexXYjPucKl0QKbxBxfLCeX0VaAy4/LN6OoVgVyMVoTug7vn 4JkRUoxV25/n1ZPAMrzcvQLlNHwBSiblRXZxW1J/YH9t3F0pVnFEzkxW9TfotlEu3tBJ of0I2wiGPJ3XLEGcae3zDtA8r2o7xewf9A1cDIohmUsCUkJD+EOCcecM4jd7OdgbpUpa y1UXzvuu+DrIwi3Oz7aJmdqh5h+Ra8diPCLs9oiDaVPDuCcgssJ0BU7h89ANelJz6TmJ Pkhw== X-Forwarded-Encrypted: i=1; AJvYcCWCCsi/eS+KaqGN6R9H9D3JwsQxCKRY/YJPndbU+wcb9tOprWlKXFr2Tx74tU6xv1UksNuKYx+BxYPCh30yR4hhzSE= X-Gm-Message-State: AOJu0YxPjgHZ5dVFttaHxek8CdiNTqdXloJhJBUOEPHoNFE7iL2nRFu8 v9r9IgL6MOglBuV0lHfs70fMtYbVSf/RdOp1oTgoa3G1RnEcQ7v9fTKzUagvD93ZvirV4LWH3I7 wh90AlxD20g== X-Google-Smtp-Source: AGHT+IFyt7OjPNZMl6PbkdfYNDPh8L+dPRBgusnHtzyUmHnXcEp/uNI1T+enUzqfuMGxALw2f3LiWe2F0njYig== X-Received: from beeg.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:11db]) (user=jackmanb job=sendgmr) by 2002:a05:600c:358a:b0:426:5ff0:1b48 with SMTP id 5b1f17b1804b1-426708ef8b5mr784025e9.4.1720803677551; Fri, 12 Jul 2024 10:01:17 -0700 (PDT) Date: Fri, 12 Jul 2024 17:00:27 +0000 In-Reply-To: <20240712-asi-rfc-24-v1-0-144b319a40d8@google.com> Mime-Version: 1.0 References: <20240712-asi-rfc-24-v1-0-144b319a40d8@google.com> X-Mailer: b4 0.14-dev Message-ID: <20240712-asi-rfc-24-v1-9-144b319a40d8@google.com> Subject: [PATCH 09/26] mm: asi: Make __get_current_cr3_fast() ASI-aware From: Brendan Jackman <jackmanb@google.com> To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com>, Andy Lutomirski <luto@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com>, Alexandre Chartre <alexandre.chartre@oracle.com>, Liran Alon <liran.alon@oracle.com>, Jan Setje-Eilers <jan.setjeeilers@oracle.com>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Andrew Morton <akpm@linux-foundation.org>, Mel Gorman <mgorman@suse.de>, Lorenzo Stoakes <lstoakes@gmail.com>, David Hildenbrand <david@redhat.com>, Vlastimil Babka <vbabka@suse.cz>, Michal Hocko <mhocko@kernel.org>, Khalid Aziz <khalid.aziz@oracle.com>, Juri Lelli <juri.lelli@redhat.com>, Vincent Guittot <vincent.guittot@linaro.org>, Dietmar Eggemann <dietmar.eggemann@arm.com>, Steven Rostedt <rostedt@goodmis.org>, Valentin Schneider <vschneid@redhat.com>, Paul Turner <pjt@google.com>, Reiji Watanabe <reijiw@google.com>, Junaid Shahid <junaids@google.com>, Ofir Weisse <oweisse@google.com>, Yosry Ahmed <yosryahmed@google.com>, Patrick Bellasi <derkling@google.com>, KP Singh <kpsingh@google.com>, Alexandra Sandulescu <aesa@google.com>, Matteo Rizzo <matteorizzo@google.com>, Jann Horn <jannh@google.com> Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, Brendan Jackman <jackmanb@google.com> Content-Type: text/plain; charset="utf-8" X-Rspamd-Queue-Id: ED78920033 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1iipqoype7jxigohy85a8k8xa3xfky34 X-HE-Tag: 1720803678-419373 X-HE-Meta: U2FsdGVkX1/zIvsLmupD+OFhN6aySst+ygtF60K4uhw0G0Y0p5azMaiICVlAg3FGIEDlg3JM0Uhg642gsOCQVBPgjzpqj7iNHNY30rpluLRNBn+J/mBWcE8Vy3vXxo7pOll1Vgitlv7gEQDH8PnbE3JARVbDy9PqupXdtIDVeqyVXL1folyjN5gLCkjfmSVIMdsLHy132P2k9IWC8FqpSNmA9tFqspVlJOhEc3XjCJVvqlMseWRlsSkraKEaRnx2sCSlze8MYhUWXh5nuE4gnUA2f6M7ttaQkgg4LFwRB5cqnLw4yCLgMX2cApx9RulefhO5GijvfFA4g9M9jp22id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Xyi2ohuwG29hTDLFiNLLT5zmaG+E/cjr6aUm69m8wlQ6FFEkp1G8UYJ1fPLQt6RUQCwxOvfcIzKsuLMHK/utYUhdr+7CrH/XByXFB4CPBgG4Qz5W9FuCUswHf9yUsdmf1vG818hThMgZ5hoiixmbVos8EbYgMq5az3gRH4EbQF+ihUaPFaWrc7i7Ae3Lj8RWX4lT9A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Address Space Isolation (ASI) 2024
|
expand
|
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 34d61b56d33f..02f73a71d4ea 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -18,6 +18,7 @@ #include <asm/cache.h> #include <asm/cacheflush.h> #include <asm/apic.h> +#include <asm/asi.h> #include <asm/perf_event.h> #include "mm_internal.h" @@ -1125,14 +1126,32 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end) */ inline_or_noinstr unsigned long __get_current_cr3_fast(void) { - unsigned long cr3 = - build_cr3(this_cpu_read(cpu_tlbstate.loaded_mm)->pgd, - this_cpu_read(cpu_tlbstate.loaded_mm_asid), - tlbstate_lam_cr3_mask()); + unsigned long cr3; + pgd_t *pgd; + u16 asid = this_cpu_read(cpu_tlbstate.loaded_mm_asid); + struct asi *asi = asi_get_current(); + u16 pcid; + + if (asi) { + pgd = asi_pgd(asi); + pcid = asi_pcid(asi, asid); + } else { + pgd = this_cpu_read(cpu_tlbstate.loaded_mm)->pgd; + pcid = kern_pcid(asid); + } + + cr3 = build_cr3_pcid(pgd, pcid, tlbstate_lam_cr3_mask(), false); /* For now, be very restrictive about when this can be called. */ VM_WARN_ON(in_nmi() || preemptible()); + /* + * Outside of the ASI critical section, an ASI-restricted CR3 is + * unstable because an interrupt (including an inner interrupt, if we're + * already in one) could cause a persistent asi_exit. + */ + VM_WARN_ON_ONCE(asi && (asi_is_relaxed() || asi_intr_nest_depth())); + VM_BUG_ON(cr3 != __read_cr3()); return cr3; }