From patchwork Sat Feb 3 00:23:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 196118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp776234dyc; Fri, 2 Feb 2024 16:30:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGehCwDduhAWni4FARbG6tA2Wa2GLF28l1O5E3AAP4/QrqQfrqDak3VCg4Q5eLMP5/qxg5C X-Received: by 2002:a05:6e02:2185:b0:363:8919:814d with SMTP id j5-20020a056e02218500b003638919814dmr12874442ila.22.1706920242769; Fri, 02 Feb 2024 16:30:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706920242; cv=pass; d=google.com; s=arc-20160816; b=h8i7yGFyPKEvWb6CM65bJqUru0pxp+OK8BO7lNwWb6XZG4N17oqJP2CrvwydY6tmvg YFPenNY1mzkA8706iZBxeV7MC05fWMZW1We9onZ4ALZsuATpywGh3xE6HT6TW/7eKe+y hGyp73YcsqR0PYASr52zDqz2iFH+HZAeP0Aay7l/16jt3nLFIEC+NGhi41Jgs2eQLXQV o2KWxKtTbIf6qee0mpamyXdBhIEWdYdvet3EW0HVdxea/x6luHqOaL1mSJhs+oijE+6Y lGyVA3Xqs6BIFhxw2EtQlrT/PB+TpN4E4BQyY7gte1/dYiMzkx8ICWg4Vx50aBOK9Mrr Nq/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=cwT/GAm9mwG3ErXCbNNgFODtOKZ2Q++g1RjuNuyLwPU=; fh=DDV367v4kCCr9xA31YOaPVzLZAPUaC4+J0X+1IhPYdQ=; b=s6SA+lJmOCOopD/zMCQseIP8dJGjB0T30PLG3Em2oSYFlnICJ/ymsi6o1EeIMOg9LM osnLTvVjaDsu5YRnbo8lxzHNgnG9CLyVHgEhZTGLGY9UUTxrWWQEJ3mnAeshbYYWOG3W RruuBcW3Q6mRz+XyDuDmahSQlkaUZLQhzACpaLTVVfVyQ4bcxxnhTeja7jZQvE5poapb SNtdctz5r/kt/hclDN5qASwDwp9b4R5RdSYrtFfh1Zz935W1MWyMGVOim85mWrfyDdzZ 6OeAKmMyaZiBRE2DPD1TraKsaa+oRwPh13q9sOO+2xrnwDP7tEHDAGxUdfFmd4jDCzhj xaWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MYQpIBes; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-50772-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50772-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVDjCzEZqIczLSo605GoWMtOenlTDb/Qh0x8F33KhE2DBM97SS+Nov4mvY8Mjc8vH0Uw6hxauVJia/ynZvl+vqHNNxMvQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r19-20020a632b13000000b005be1e55546esi2329066pgr.51.2024.02.02.16.30.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 16:30:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50772-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MYQpIBes; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-50772-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50772-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5C60AB26B4A for ; Sat, 3 Feb 2024 00:25:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1634F51F; Sat, 3 Feb 2024 00:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MYQpIBes" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 AFB776FB6 for ; Sat, 3 Feb 2024 00:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706919834; cv=none; b=KiWjIt46STqDfa+Przzk0SPr8uFMoZSsA/XVTA6JHuL7o7wnCJJ33mRXjtOAJ/IQKd/WB5q9Hu5jtk9dy2MDVLw1NWSrLGackcZNvQpDSMqXKXgnQ07TI6TNHMcnafrsYkqZfGCDIATD2r8gPD1PbtGm2a1zcJHAm7WRMtoWi/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706919834; c=relaxed/simple; bh=WRSYmBjqMlFqc1HY3FJ4/F7rWHbJJwswChlMeIjfn2s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GfRN9Z/LWMM1CmIZZycIKeYpyG2bp6tQMViauWtDrVJ3xGd9pTTQkmtsezqf8kbhaGuBkRAcLVhmPMLux5tsBvkT4JbZuQ5x7TTRj47xK52uQr2N2Ms9ZqMMNqhgth8zGVfHw1M3M6noDUbQnD8S7p0GWT/fBytGqPxXCRZxj8Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=MYQpIBes; arc=none smtp.client-ip=209.85.128.202 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--seanjc.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60406626b50so58783837b3.0 for ; Fri, 02 Feb 2024 16:23:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706919832; x=1707524632; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=cwT/GAm9mwG3ErXCbNNgFODtOKZ2Q++g1RjuNuyLwPU=; b=MYQpIBesBVEjCYCp6g1CTdewc+ZsdG8kpcQH1gDUz5v/sl5O1droXSteg2xJxuamku EdEaFpdIMAp9xoHlOn0bAco/w3f2ubMxaTHbGsTQmwqsFWPiU/FWn79kS2r3G7bE9zMp m4WI0zykIV2skMPXkZB+uMyeMUA5hM6ltchfwLA2syzY+V4OPGI91q446RHFnAydkcbl vyuixMeU/6247uCJfD2c3cpeiV87jXegttCu+/ahB/0CDo8TVWXSykJEst/EMMkz9u9T ZF4Qe8y2gMQWYtIv77G3wkEdf3BH8GSNKWCRrY8he48lnBB5G6q145aR/LuqU4Yb3uKw abRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706919832; x=1707524632; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cwT/GAm9mwG3ErXCbNNgFODtOKZ2Q++g1RjuNuyLwPU=; b=eGVw7Gqx1tY2YtXTOvj0Tyv/sjdcEeZw8lnTowMZKQbE61/SXKsV5ROhGDA9MXOqL2 yY5RSp8odCpA6VYXlwdnc3wzyH+oU1GzH0W53pJBgjDlBldps1MfItVden7yNFysIrB+ NZvWoh9ckcpcfsmCq7K4R/i8IcoPGPWCbeBh8ZTmG5EpfTxlACujS7EBHSh5kLyURRD3 2irlWhRjV7rVxCAPikSMzrZeRpgGa8XM0EWNfdezo82esFt1ipIMW6tUPn4AhVg5FwwT RNpdeaFji73mL1YggHfISkJH5Aj1Yt6GsacP3QI8h1gO/kk3QL61D16gpBQRmYXQZraV GASw== X-Gm-Message-State: AOJu0YzxY1kE3c/gGN59i9M9THBtDs58QWKB0tpiEnTj6GULbotkF2th Qauk+UpU547SQQY/fSjOmAyWQoXs4Db22gJJI/QENXl/7E9StNmpzoF+PRUllJxAMmfvvMpcYWQ y1g== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:690c:9:b0:5d3:5a95:2338 with SMTP id bc9-20020a05690c000900b005d35a952338mr939298ywb.9.1706919831997; Fri, 02 Feb 2024 16:23:51 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 2 Feb 2024 16:23:42 -0800 In-Reply-To: <20240203002343.383056-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240203002343.383056-1-seanjc@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240203002343.383056-4-seanjc@google.com> Subject: [PATCH v2 3/4] KVM: x86: Drop superfluous check on direct MMU vs. WRITE_PF_TO_SP flag From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jim Mattson , Mingwei Zhang X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789835600745624440 X-GMAIL-MSGID: 1789835600745624440 Remove reexecute_instruction()'s final check on the MMU being direct, as EMULTYPE_WRITE_PF_TO_SP is only ever set if the MMU is indirect, i.e. is a shadow MMU. Prior to commit 93c05d3ef252 ("KVM: x86: improve reexecute_instruction"), the flag simply didn't exist (and KVM actually returned "true" unconditionally for both types of MMUs). I.e. the explicit check for a direct MMU is simply leftover artifact from old code. Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c502121b7bee..5fe94b2de1dc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8804,8 +8804,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, * then zap the SPTE to unprotect the gfn, and then do it all over * again. Report the error to userspace. */ - return vcpu->arch.mmu->root_role.direct || - !(emulation_type & EMULTYPE_WRITE_PF_TO_SP); + return !(emulation_type & EMULTYPE_WRITE_PF_TO_SP); } static bool retry_instruction(struct x86_emulate_ctxt *ctxt,