Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1081156pxm; Wed, 23 Feb 2022 17:38:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyENsytKj0+dl1uESPqiovqf3ZDwFFdUnjNoaGtqNeXookYiMS8Dj14mrk8CmbuJXb+cSpP X-Received: by 2002:a17:902:f605:b0:14d:bd53:e2cd with SMTP id n5-20020a170902f60500b0014dbd53e2cdmr269054plg.164.1645666679852; Wed, 23 Feb 2022 17:37:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645666679; cv=none; d=google.com; s=arc-20160816; b=yr+hTZ4jXiR+cxT86TLUteFJ/dtIWuAw1c37QYPBgjVFinKTvsVm21u5m5R10D3vkU HRdAahsx7ZCA2MveEOheSJPdB2PMUtgcACuaYSRtyaS8SrGZvEWeInEXhcBAEOyv9DDo BH0YryaWnBZsgYz0EMMasK3WGzoZ2sCzAOEM9DFVEqkX3OUvgVRORd5bhG4QbmOs9Oxb qRCm7JU9SzXTnJQqopGAm5Pen4rf9+ATFin5xw44ZFMGxD1O15iFvu6+Y0XaQR49iGYX 4I00dKI7uDCz7tx/OniWptrqtOXvwLGZoxfkECOo+vkuJq8ZoW5KSjSiMOmwE9lmOwZv JKLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=cWpgk2PD8ywov80MgvYy738g6oDVkPJMa4mg6Kd57WI=; b=Wvb2hor60p/NlUZgisISAYiKHaQ4aygSo2JzGAivM3PcJAJxB9KEW3/bF03D46caCv Zl2RDGWX+f4pmmDokW3LdtXfoRV+DoekWQOfqz3Iu5zlWNWOfHHuI5bYBDJn40Bs/5i4 IeyYxXi/bXvgA2W3IvO6K1t8USMebl2t4chR81UkcnYYSsRigpeQxJYMzIk1JpJyTVjc OYhqF9OK0qRjQiaq0PqfCXMQpvz/nWCJpMBblbMlfFf8U+8TVYRDvugxcyhccDRPfTSj fH3qzcZBqSa1IJ8ohbccozXaOm+OX9hdmn0a8Dd1T0nLkjukZulLCMbLaiQ7fN7LYI4+ 8EFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=EONmeIZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y15-20020a17090a644f00b001bc589b20f5si3766577pjm.36.2022.02.23.17.37.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:37:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=EONmeIZh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D30026F4C5; Wed, 23 Feb 2022 17:16:05 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238459AbiBWF3Z (ORCPT + 99 others); Wed, 23 Feb 2022 00:29:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238478AbiBWF1V (ORCPT ); Wed, 23 Feb 2022 00:27:21 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D5536FA00 for ; Tue, 22 Feb 2022 21:25:35 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id w1-20020a05690204e100b006244315a721so15103484ybs.0 for ; Tue, 22 Feb 2022 21:25:35 -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=ESNwcdSrhhzBzcM6W3/JrafRFhqX3vAFFQORC5ayZmuSAZcJsDDvmYfu765Us7vUVL rmbF2jH3u4QM9lTj7wBIIdpSn/p15J9GxQkOi54ylP4ryK4Jg9WHI4Bs6Q8CS2j6KjnH o389/Kb4kJxVEHAr9WG1vZvHuoJkBCScqZPMCvIdipgV/bsLFcqNRfzlj3SZH5tH7PHq xPb8BHm0mN6oQc8GoUjaZoDKBAW9u2j0DQQG94iSqSqX7apR2FPWM2vbdyjKDjENaA2R ATvw1enppYrHGPuPkyoJ+ylu85IVzZrC0/NY0WERBZuegu01wlRhTCo+UGLK6yj1YnPo fsog== X-Gm-Message-State: AOAM5308wCf0ZPaGpOIAQ7o+N+hT9jBEHFLiTLp4wW50Ta9MRa4GXOEp Vy9lOeFfTl6k9wqJLjCLeVxUf5RR0FDvHEVD9BAhgqEivp/VVxaKF2Wi4AZyPBbQLlTL+KOEKqB m09ycLQK2y8/yRYQB7rpip6Q4lja1L7IYx5Hm1uZhLLUzWjA3jTmMDYjDe1d4awh0mZrrJfnr 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.35.1.473.g83b2b277ed-goog