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: 13732017 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D8C017997D for ; Fri, 12 Jul 2024 17:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720803674; cv=none; b=N9+OlUtn3xZFUngt1gf3QMYnvukZl1mfTwmOraNzjzIReiUuiX//pFiSgZdse6iBQrvQ/3PDkliFKDbqrjleEwxL8dTsrFeribL5dCTz3HlLU8r2H3n4RRl2ULRtK4zhiE1lQk5c7h0ba1boBGAeEd1a5AYyLU1DqVndZ/ViWo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720803674; c=relaxed/simple; bh=/oJj5vwlZeyskk+GmP45ROP1br4fXDWKMm3Wo5pDy64=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bmlQEoi8RvCKCdo0SgHfJrmQDB0kaeMAdTsDEMjotK6uEvwoGLxF9lDDRI08iUmD0cW/JmrTWfHoQBS50jy4JyK8GBeldl+avV+vYOYmX2B2nKpP/wusBISiJsj4LNc67X7tiOu2ADJyQA3ElFrFCSG2jkYXXgiqEHkKoD72qLc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4FZd6+vY; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4FZd6+vY" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-367987e6ebcso1585640f8f.2 for ; Fri, 12 Jul 2024 10:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720803672; x=1721408472; darn=vger.kernel.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=4FZd6+vYdHNetqPYBVq0OPYSqiH0u4eFWuGqvPgUwr5y2oHbgd1OBwSI0/EGJlafdI jT4+AH/lgQe0XE0MoKDXpEx5bEgf6qfZWjvZIhFHsK6qy3PkvPi8vDUP2QPZBkDIqh6r uWY1eumCkH+MeDnNc1KjL7zLetrKj7s/YUfHm8NYLPNJq5UVqs4BOVL5oZtyVJ78hcAU J5GqG0/OtR8iAj8fesdhbofxo0Wez/hIJpHboOOUqXIXweYtkLbICeOzvZ5vPSFqRnn4 qY0US9FYSSv2Vf106dkH4M4q2wkgIvzeCXa78ol04YEGW4n4gcv/yI99+uaLlIbQs27p dELQ== 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=sBo5E5IZOarL5oyDYwA41mL7jk4bK5TLHTeyjqSPybVfgTgKmdSz7JzEN6GE99Th4f WnGEhOYn+eHdrkVjx3R7f8+LjThZXvfRB9+AZ13rg2tUFnpf2ihTsLW6gAHGb+TtcLhD aR1+horNTuw3C0jeyhP96uqnWvu4BNzowvr5hA4SkNQpwb7YenNMv5BCZucCol/1hb97 0OUSVLb4DOwe6yEiv/FnnzaItpSEjEF8BA9soDFu2mUjMjNnDqufhlL9G+QNmWruBcjS 1XSKA/BJU9YSpJAuvpES6rm0Ow+YjbqLsLFNqyMWouAiVQOkWNzZonFToMdRvbl4s+Dx WSAA== X-Forwarded-Encrypted: i=1; AJvYcCVJnOZ4nJNuK9jGqixjqhyah/Vp4Uu1TV0uIFaN99ihYaCujfNPQlk5HGos4m6yoyKsH3E1KlQzkNWICcb2sqmkk+ej X-Gm-Message-State: AOJu0YzYyQlPhbxEvtHmDabHubtD6mM4AtQSqsW3WHlIo15eofETGnxb RthmS+1f1BDrWsAwE4awRFtRyqlhamLUu+xeBjoOuZoZ9hDB+3BhUITkNLoFAlxHnAIXAy80g24 6RxuClPIfaA== 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> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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); /*