Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22534406rwd; Fri, 30 Jun 2023 09:09:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcL9PHCcv/mcVnB2PCoNL+RCnDcmWcAI0MQ8H4M1tL0DeaLL0ia7IcdNpApQmoegJ2KalW X-Received: by 2002:a05:6a00:1151:b0:67a:8fc7:1b61 with SMTP id b17-20020a056a00115100b0067a8fc71b61mr4162285pfm.11.1688141373239; Fri, 30 Jun 2023 09:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688141373; cv=none; d=google.com; s=arc-20160816; b=EBahBswOor2qckGzTcsP+ZA0RaKleKO/87jcFhfxsCY0uZp17Ai35og/ySi2Ky9wqD hxgDycQyBqb+lX1oKUhGSbrR1ivvCRdygWGuqLkH9oTo5OLBWbWeX+0mgMzXb/MLqFK2 hDKo6mDgZScjPWpcBx57RLDNceRuDHarqdKgt+UHYWSBZQ7oyvf7F+2A8w4m/O/csnIe xFeURxeNy01aJlj9IGoqirHUq/F8qiHr73TbW1gTIltkLuihTXoJsNKdI+1j5gb6WFAz TqX8PxED+RP55qhMaezKqa17bkahrZqUxT8X7rZVmgxFF/Z3zL9a3rT3F8zS7f6jJHO4 aqZg== 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:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=2bdagaR5N1qIFZFzXqIi1uWqn/bfAiw0c0oO57kq+nk=; fh=3czL5QBflwGJiswzjBJ9DxnF4nCy1F9yDPF/4yrxQvw=; b=ExVpkLwBOfODezLAMcGpQScR9rubY/ISpzw5yKiqq0iXadrgDgXKvAU2GpOjY4sk/t BC1gTb9MGmP/gtrxaC+jfVZlsDEbTuR8ECcCrV2yZJq47QvKsAdliHrMcv18durIA7FL sYOchR9pbUKW66RYalbWJ8/qGnvf4bFjGnNqm5xJpyarJzjD36uVU7od/EDjEs0xrQ11 XOsFo91YUi6s10fTsuLljJHjzu7y+EdR6AmuHLI2UdUs6p32cvoKYvUHfMDm03zkgIib hovp6I9Ed+L+uSVspoCKhKcSEKTpQeHDY68gdJDGsAYBlkyYVgpC6Hg2FeHQvZeXl71J QIGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=uXJ9O6qf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a634a03000000b0054a291a0bf9si12584776pga.672.2023.06.30.09.09.19; Fri, 30 Jun 2023 09:09:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=uXJ9O6qf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232726AbjF3PhL (ORCPT + 99 others); Fri, 30 Jun 2023 11:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230308AbjF3PhJ (ORCPT ); Fri, 30 Jun 2023 11:37:09 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00E06B4 for ; Fri, 30 Jun 2023 08:37:08 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5734d919156so19217927b3.3 for ; Fri, 30 Jun 2023 08:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688139428; x=1690731428; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2bdagaR5N1qIFZFzXqIi1uWqn/bfAiw0c0oO57kq+nk=; b=uXJ9O6qfWdldgDsjuntnftMM7qQJfvFQeahSqQ1ggMIEOuduwnzqedr89fbQSwyX3y 69liEDrUS89Mna80gPnZj9SSWOxAXWQ+AXL+3EpJDL5bi1yWAGYi0dJxql4YZx7q+rHo kPwDS7Zc1fuMZ6eJ8gzVvmdfHx/U5edBjcuSC2K/3aCu1tMTMFP7CuLH9LfXT/gZd4wM cVNuNiAjZoK8uEWnnjwV6qvCsxJOiY06W+8AytXoa8q1N7XdnkvDLNlzj38wkClMWZnM zo5+GIMafrtJOQCoHaSghQo76lX4ae7GXByj8elgsIvYBEp7ljkzDcRkbdW0cTfXc+qr EeCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688139428; x=1690731428; 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=2bdagaR5N1qIFZFzXqIi1uWqn/bfAiw0c0oO57kq+nk=; b=Tch7qIQ0HvMhYR4BDUw+y43aw2EH73x5iEVaSGJ8KJxLGZgRRc/UdMtNcTYgdmpxqV FDbfiYJ8tWpxvEYvvHR0bRegeaOLc5b43wbeEsgC5PsRLSczI57V5DzGE/VsHaX/+M2A iddubiP7Ay0Dx8wEB/qnq8X0/5bB3/jDScrtaOq0HrABgUlgu1FOd+5HRqIPYuBNAvkY vhEaZ6vgJQJTdawDlmpYu1zA02iLK532hfNeK3hd6/dYBMUIWrVdHb3T/in5HOqd8bSd su9DkVbrdutKqXe29ALR/aEeEe54dOdx89DjAYF6gBWlmXKc8iyws/LUmLBkd4yXvYCT ZkGg== X-Gm-Message-State: ABy/qLYTCS25hEXxILPCE9GTcyOHNgIUUWN8J2keLloa1y1OitUb5YAS eDTZc2Cnv2Tb7zVTEl7/xbjTpLzD9Ts= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:8d52:0:b0:56d:2abf:f0c with SMTP id w18-20020a818d52000000b0056d2abf0f0cmr25114ywj.10.1688139428278; Fri, 30 Jun 2023 08:37:08 -0700 (PDT) Date: Fri, 30 Jun 2023 08:37:06 -0700 In-Reply-To: <20230630050157.kurgzdcpjngs6w4k@yy-desk-7060> Mime-Version: 1.0 References: <20230628071217.71126-1-ishiir@g.ecc.u-tokyo.ac.jp> <20230630050157.kurgzdcpjngs6w4k@yy-desk-7060> Message-ID: Subject: Re: [PATCH] KVM: nVMX: Prevent vmlaunch with EPTP pointing outside assigned memory area From: Sean Christopherson To: Yuan Yao Cc: Yan Zhao , Reima Ishii , shina@ecc.u-tokyo.ac.jp, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, yuan.yao@intel.com Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 On Fri, Jun 30, 2023, Yuan Yao wrote: > On Thu, Jun 29, 2023 at 01:30:31PM -0700, Sean Christopherson wrote: > > @@ -3834,8 +3822,8 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu) > > if (!(pdptrs[i] & PT_PRESENT_MASK)) > > continue; > > > > - if (mmu_check_root(vcpu, pdptrs[i] >> PAGE_SHIFT)) > > - return 1; > > + if (kvm_vcpu_is_visible_gfn(vcpu, pdptrs[i] >> PAGE_SHIFT)) > > + pdptrs[i] = 0; > > Hi Sean, > > Should this be "!kvm_vcpu_is_visible_gfn(vcpu, pdptrs[i] >> PAGE_SHIFT)" and Yep, typo that inverted the check. Thanks for saving me some debug time! > turn the pae_root[i] to dummy root yet ? No, zeroing the PDPTR is sufficient. Unlike CR3, which is always "present", PDPTRs have a present bit and so KVM can communicate to hardware that the entry isn't valid simply by clearing the PDPTPR.