From patchwork Fri Jul 12 17:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Jackman X-Patchwork-Id: 13731990 Return-Path: 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 DB267C3DA45 for ; Fri, 12 Jul 2024 17:01:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C47776B009C; Fri, 12 Jul 2024 13:01:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCF436B009D; Fri, 12 Jul 2024 13:01:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D5186B009E; Fri, 12 Jul 2024 13:01:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 795796B009C for ; Fri, 12 Jul 2024 13:01:15 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2CACA120C23 for ; Fri, 12 Jul 2024 17:01:15 +0000 (UTC) X-FDA: 82331716110.27.ECA0A06 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf13.hostedemail.com (Postfix) with ESMTP id 3343120020 for ; Fri, 12 Jul 2024 17:01:12 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=hiYWvOhG; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3V2GRZggKCJoD46EG4H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jackmanb.bounces.google.com designates 209.85.221.73 as permitted sender) smtp.mailfrom=3V2GRZggKCJoD46EG4H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jackmanb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720803647; a=rsa-sha256; cv=none; b=ncELCe8dmYY7dtndz+6N7xiWfcozbFjlUpRTbJV//+qrSAGQ2ZTGXpoLk/1w3TJz9k4WdW +6dLpgbiegZ1+jxeHZsN4uLVyMdmOOeGRELppBan/cBD55W9EIjaq96BHJU1odt5QKyhB8 H1EvjDkth1pwK2c/UaUWi1GkSPITmiM= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=hiYWvOhG; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3V2GRZggKCJoD46EG4H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jackmanb.bounces.google.com designates 209.85.221.73 as permitted sender) smtp.mailfrom=3V2GRZggKCJoD46EG4H5AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--jackmanb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720803647; 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=HhvK+VsrCDIF0zdCgKI0fd0HHuRdBdA78SeRsMH4q04=; b=g+awT0zFiAOagHomrzmKUIdDvBe4tTx953j3DZBYk9l1JKrkHle5dAqNppaGQYQvdwFm8U VOBZeftvHB59G3VZJKw3nEqr0FXm8Bfc625itN7fpzbDbgnGEnqB4+ntJosK40twKlw1GC O/P3omMzociv8Y/3WT+8cFlGXwSa+3k= Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-36805bfd95aso514276f8f.3 for ; Fri, 12 Jul 2024 10:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720803672; x=1721408472; 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=HhvK+VsrCDIF0zdCgKI0fd0HHuRdBdA78SeRsMH4q04=; b=hiYWvOhGTyqtcFSobfiv6gR9FV6NyolRqBJF92fIDJJaMn30AU9FC+kjCQeU8UlHdm oHNrV8XSSYjHltzxE2+kbNKbaIk+kNXrK7lQzi9NFIHLczVuLQwFnTgNf7dHPuB8N0/D QWnHFACFNxeJ1YaoE6eOLeY25S0Fx5hli/dr7IRYw5i9bw+BYTuivFBABSWlKL4oXtDE Z2SeafDi6hmTeN40Xnm5XpxM5og5P/xpsCoLyTfuivA/LvY+I6FvpFHvvkrXgfSaDhsT /KoDstpOJuzpndTvBjhpcLDyNYALhu7Fqm7YPIzyyHeIZ0m1fguyU9peK507tM/FoYhC pL+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720803672; x=1721408472; 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=HhvK+VsrCDIF0zdCgKI0fd0HHuRdBdA78SeRsMH4q04=; b=rEffcPeihLVzI1SBT7J/33CneEQdrI7OjQbVq6Gy/7KgOwQoTHxjRUq3nG9HbpmSex 4FwqJL80XVKwuCz2ST1vTkWRAEhWYFqJZO/VWM+qDeQntugh5YJ1TrGfO5bFlIpbAPBB TydsfOvASYC6hlahePWj/iiLyy8PHMMW+4HVxy0MPEulgqGYW8kW2wBEQCMdFLtoDiXE Fh7xxUAAu2bZIKr6hsR6inc0tvYaYvUm4b7NI8qyEFyvNsjWeKAVNh+hx/+idbJNUCrO lnX0cOHPNxHxuxzEQ8itqdyAu9BdiJDFgCaVTnjv84CNf7f3tAkjHhvI9IfJLypNjCU6 wC/g== X-Forwarded-Encrypted: i=1; AJvYcCWiCXTVjsB36AQF50i3WnScWteaAvoaLFdD+Cb/dzN4JgGcL93X5vnP9LN/EzZJwQR9Q3QOnpey534NBT1fugq2rUE= X-Gm-Message-State: AOJu0YyBaZx6xGWBlQCrOCIE7NDsCEw6BOZdArl4dBC945yQ4CX8LytR P9otGdrOS5ULkEyY59JuwiW5hpsV+Dclmzsbgl5oXOippAMMfZg0N1lgc8bhbsKEKSavf9trLf/ iDv24qcu+OA== X-Google-Smtp-Source: AGHT+IFAPE6Abc5gQhah4PjzgMavZ5HwflkhPdDu4LbVKDPqBKd9rbMZcjfutEvjASrTYbwEe+XhPDdeyFCaUQ== X-Received: from beeg.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:11db]) (user=jackmanb job=sendgmr) by 2002:adf:e988:0:b0:367:9db7:d6d4 with SMTP id ffacd0b85a97d-367ceac39c9mr19900f8f.9.1720803671416; Fri, 12 Jul 2024 10:01:11 -0700 (PDT) Date: Fri, 12 Jul 2024 17:00:25 +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-7-144b319a40d8@google.com> Subject: [PATCH 07/26] mm: asi: Switch to unrestricted address space before a context switch From: Brendan Jackman To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Sean Christopherson , Paolo Bonzini , Alexandre Chartre , Liran Alon , Jan Setje-Eilers , Catalin Marinas , Will Deacon , Mark Rutland , Andrew Morton , Mel Gorman , Lorenzo Stoakes , David Hildenbrand , Vlastimil Babka , Michal Hocko , Khalid Aziz , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Valentin Schneider , Paul Turner , Reiji Watanabe , Junaid Shahid , Ofir Weisse , Yosry Ahmed , Patrick Bellasi , KP Singh , Alexandra Sandulescu , Matteo Rizzo , Jann Horn Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, Brendan Jackman X-Rspamd-Queue-Id: 3343120020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: j1577uaeu9pjbffircbane6rg4q7iqe5 X-HE-Tag: 1720803672-63084 X-HE-Meta: U2FsdGVkX1+bGdXLk8LhrKBXOM6VlPRRSDg81YjYvhADmWo19nFTuwN6T4yKdAtQPAxAz8flgefgX0JciNsW3tgYpLFXc29Fed2kqNRAc26tqSh6ZlebKTl6wFIG+B7AOUumID8NMDaIHNweERqOTwH4YtOjPjh131gD0NACl3UHiWRMLAcuzT4zggcEZd/MEeZZ5WSI1H2mgafqUg5b+BDz0UZlU9wLmTb6X+DllnXmMjTg0cGNdBuYhSJNuu6fLW+wBshrnqGD8A5EYDrFpU+qaLW98Cw0QepJNxHSh1o13vzNnSFQmy7qp9g0H39K7FmZ5geY+sGeIqvBs4xST2VdoRaMjGHmAc+m96p6NwLEhiywPAItX1wFS6OZ665P7lFAPTXrak+6r3IJTeAPTMho4b6EUvJpyYknCKyDeUrUzSrWS4MNx0TS714I7qrZQoq7YyDaojx/GgXE4bNHx/4VmTwXwNRwImFlHsfZrlz8gP0dwKCEP8UYnyzY2DH2YfLh0r8PYVOBaa1auIj0VM0oTdq1kzwp5wRxyVzVpzOfIH1eINJc2R+7BzJI9V66Pjw1O2H7/A7miqlcQP9RIAXkHDTdNPrcpwC8YWIpcINanAExvcaKNWeYBbAGeYEYZObagnPSHkzcSsRGQgkGpeZRtt1qkn/w5EzZGtfVbygf9KOLAZppwTve6OMYXBofFpuKYUt+PSSG36VbY+f0koQ8QtaI8Zlx+GGP2LB8gsHsSqn1YVt5vAXrGoWWpUH9StNtat5DkV1FojA1jji3F06foSF23JMbz30ZpJ5rjoPT3Xgq1VdYjdJG/BAVm/TITO84atCS+CRTsvWQSv6uWTOUDLEgA80TL9Gn7uyvi3N+2sgIR1NlitMDRro5dvgDPRr/RsUZeeNMFTEtgn3Kis6SSjqABx8d7QVjeB6zFQ8yaUmv6vvf0EsXzlT4OvfER2tFewfuZXvaEYFBYXG gakPyIK9 v1ckFsKFIaaCNIu1yfgWUh3Unf6pHpziAjXkpEXUCNQ9ApOv70FGKuXE+oPXFjfQTdHycE2srKTFIMbxjC4dSK1Bs+pj0NyC0r50ryKEAdgEn5UTLf+4JBQt3ioSKq6FL+ubFZFM/pz7aSerEkK0D61Ww1gvc3z4Kc6bu72BI7vDCRhU86Dv9evmHddHEZIcg7+1AKDcT20yLN4iaZLSER2hthAoN42b7ZAnKE8fg/PtCg/8SqgKK86HTsJCfFmrEa281fgo6ekvAXc4jKKXCb8+CNNXlzo6ZDyIrrLiRBICVdzd79J1JPYUlMJdLRBRVE/LEr7XWm2WiQ1IUDIGUZnmxRutu5xshNJZfpT8EU2gdOA4LogrGCroSsVu9dZM9CYYNM49wLtXZab9n4zQHRBUIMS7poZSoAOd1/hEi13oPfQnTuZIfLXY+GH+ypPwIl37QWpsIcqVECrTuWf+CdP86YwmmKnRNEAjIqeTxs/N0Nzz6R1IS+cEFIlolh/+93VG14uSDx1mERMAx4KQV6LzNMZhKY3zC5i8kvIK6Pn4crOSiRjj6VmNL9g== 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: List-Subscribe: List-Unsubscribe: From: Junaid Shahid To keep things simpler for the time being, we disallow context switches within the restricted address space. In the future, we would be able to relax this limitation for the case of context switches to different threads within the same process (or to the idle thread and back). Signed-off-by: Junaid Shahid Signed-off-by: Brendan Jackman --- kernel/sched/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7019a40457a6..e65ac22e5a28 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -77,6 +77,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -5353,6 +5354,8 @@ static __always_inline struct rq * context_switch(struct rq *rq, struct task_struct *prev, struct task_struct *next, struct rq_flags *rf) { + asi_exit(); + prepare_task_switch(rq, prev, next); /*