From patchwork Wed Feb 23 05:22:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junaid Shahid X-Patchwork-Id: 12756406 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 ADBCBC433FE for ; Wed, 23 Feb 2022 05:25:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1449F8D0023; Wed, 23 Feb 2022 00:25:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A3718D0001; Wed, 23 Feb 2022 00:25:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E86C48D0023; Wed, 23 Feb 2022 00:25:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id D670D8D0001 for ; Wed, 23 Feb 2022 00:25:29 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9D8C88248D52 for ; Wed, 23 Feb 2022 05:25:29 +0000 (UTC) X-FDA: 79172906778.28.CDE59D6 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf15.hostedemail.com (Postfix) with ESMTP id 28447A0006 for ; Wed, 23 Feb 2022 05:25:29 +0000 (UTC) Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-2d07ae11467so163396527b3.12 for ; Tue, 22 Feb 2022 21:25:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cWpgk2PD8ywov80MgvYy738g6oDVkPJMa4mg6Kd57WI=; b=EONmeIZhbgQ2Ix8S9q3J8G/HTiRJQe/uAmut/mIfTv5CIy/cqk4x/lLfaofIL6ZsPO 2DK7UMkGosmFYOPK8XbKYJ2B7I4QKSD7X8xoOad3cTZw5YniQxiy63dmB34fBM3ScXK9 b4M3PhJD3t0ZCy25IHGFNrU1Wai96D7oCn70Yeg5Az606EQRIrVrKV03yc49SjAoBqEY D/bmDYBLa30k0Q0T1/0E+zVvHZ7GWXBtnOemyeM6dCZ+R2nj996pZd5wNPpUZxVxnqxJ WaqOqmkCjUVkdvW9sUwO7Bbj6HXZvuS7EIm1omaeZny3PaSOUoJHhQmMblrL8LNsc6wd q1rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cWpgk2PD8ywov80MgvYy738g6oDVkPJMa4mg6Kd57WI=; b=rst9P7Ajz9Xp2lPapsW7IhBRFSTOlnAAKePmyihIYyjiPKNOBZTiT8eKuUwBbQgJYV 2H4eHTmeZvHJh2Ok+6HHBD8hGs9ntMctbt1R2zVSnmeygFfKSai656lLb9LlwyWvV9D9 A/wkCb/G+c6UbgT9jnkZWb/fQV9vqBYdsvBBUzPLCrLU0JQUAwLx02NU7R54qaK/+IoK ZLXJg11/dr8NVmDkzF3bOWCAAvnZTmKMNuBdAND6khMGK/mLQ1a7tkDc136cGqp6XS5q DNMIbNqBFT2Tz4JPsaZ+hoConyVTUsoyjZHcs6yGeLGzU8P27lUyhrIXOFfQ/Ck6R/hB Da8g== X-Gm-Message-State: AOAM530vllDqhwLqVO+pAvpA/TGnOUprA63v+6vAEXl6DZxy1ajLg6sz iw3jDG3Zj8pUE1zIFXiPYGW32OOkcxpX X-Google-Smtp-Source: ABdhPJxkXSiWBnVLfkr470oqcQZfrXanhJKcgx/q87EPE8RXSdLDTEk6wPn7sTX4KYfxfNXBGCkwiM0xCmzr X-Received: from js-desktop.svl.corp.google.com ([2620:15c:2cd:202:ccbe:5d15:e2e6:322]) (user=junaids job=sendgmr) by 2002:a25:bf87:0:b0:622:1e66:e7fd with SMTP id l7-20020a25bf87000000b006221e66e7fdmr25540509ybk.341.1645593928498; Tue, 22 Feb 2022 21:25:28 -0800 (PST) Date: Tue, 22 Feb 2022 21:22:22 -0800 In-Reply-To: <20220223052223.1202152-1-junaids@google.com> Message-Id: <20220223052223.1202152-47-junaids@google.com> Mime-Version: 1.0 References: <20220223052223.1202152-1-junaids@google.com> X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog Subject: [RFC PATCH 46/47] kvm: asi: Do asi_exit() in vcpu_run loop before returning to userspace From: Junaid Shahid To: linux-kernel@vger.kernel.org Cc: Ofir Weisse , kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com, pjt@google.com, alexandre.chartre@oracle.com, rppt@linux.ibm.com, dave.hansen@linux.intel.com, peterz@infradead.org, tglx@linutronix.de, luto@kernel.org, linux-mm@kvack.org X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=EONmeIZh; spf=pass (imf15.hostedemail.com: domain of 3SMUVYgcKCEEmxqdlgvjrrjoh.frpolqx0-ppnydfn.ruj@flex--junaids.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3SMUVYgcKCEEmxqdlgvjrrjoh.frpolqx0-ppnydfn.ruj@flex--junaids.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 28447A0006 X-Stat-Signature: qy48ox39o1p549jgx797wd8uw8e4a7oa X-HE-Tag: 1645593929-212759 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: From: Ofir Weisse For the time being, we switch to the full kernel address space before returning back to userspace. Once KPTI is also implemented using ASI, we could potentially also switch to the KPTI address space directly. Signed-off-by: Ofir Weisse --- arch/x86/kvm/x86.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 680725089a18..294f73e9e71e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10148,13 +10148,17 @@ static int vcpu_run(struct kvm_vcpu *vcpu) srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); r = xfer_to_guest_mode_handle_work(vcpu); if (r) - return r; + goto exit; vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); } } srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); +exit: + /* TODO(oweisse): trace this exit if we're still within an ASI. */ + asi_exit(); + return r; }