Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp729049pxm; Fri, 25 Feb 2022 18:31:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS9ZSm4VmLyvR5+QhLVtumpS6mmMUdAb/LN5GT1zesbVJXP0FJN0eqqaWvnF64VBJZ8Ggp X-Received: by 2002:a17:90b:34e:b0:1bd:16db:980e with SMTP id fh14-20020a17090b034e00b001bd16db980emr658753pjb.132.1645842683312; Fri, 25 Feb 2022 18:31:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645842683; cv=none; d=google.com; s=arc-20160816; b=0o3uBqqU95TSXhfXcyjFatR9BijsqtgzHbFeVTmgAtGmPKLNRM7mb1Bieixa9/lN2r qJyve4Cstl+sHJzjl6BSdZVpx9bMVatCGN5XFKj7D8z2JrPrl1Wuo5c37q1avAw0Y5d3 BhYpuALX0M9Vt/KnRPCAFcYxTYAhH1PrFnGp2TDtCcYfS269DJHdJeMNcpl6zcjsPdAC 2kvB5W8QxnUfLprksu01VqLlnAjA63sWzv7HOX/U8Jy+iSYbSyLPWSNTGAivKmNq4RcE bknmONJLY2lBWzdhZMiAflfvcZq9EIY75K3SMvvrlz7Xyh3eiX5oQfcWSd+Hm7RNFv5Y AW2Q== 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:reply-to:dkim-signature; bh=L4MqIEc/JbsQtnFnEaV173FD1GR2zeygOeGJKcIQHTM=; b=iyyJW3wdeXPen+kg39oj8QZRVFvB6UgYO+dRakbdB2qLPqG379Z8TBphrMZ8fQmWQ9 J05FgEFfekpndD6WrerLN70RgmmX1cPsZS+Qz6XUEXR9W4LIzWPCYhXOMkjZrcd/LzBO okZ4sk93yG1b+zhzPHXnn2gTrGn25sdQohY1Xmv7D92Dx6Yxlrw4p5IS/Ghpixisn92Z u3LByfYaicuakl4k2jjdWYzGDayyaaJFzd4VOwEMoKOoT4DaBMAikpkA2aLiHSHYZy2c 8am+UyL6vHz/kHS2+1iF38gqbnjznAkweYgHYecg1D84RAsEf3zjnYWvFrSEcMQAX4Ad ZeOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="j/8rVgwY"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id l15-20020a170902f68f00b0014ad5e51a03si3607395plg.564.2022.02.25.18.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 18:31:23 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="j/8rVgwY"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 16818292EF4; Fri, 25 Feb 2022 17:58:21 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232747AbiBYSX6 (ORCPT + 99 others); Fri, 25 Feb 2022 13:23:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232733AbiBYSXf (ORCPT ); Fri, 25 Feb 2022 13:23:35 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35DCF16DAD2 for ; Fri, 25 Feb 2022 10:23:02 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id bh9-20020a056a02020900b0036c0d29eb3eso3061450pgb.9 for ; Fri, 25 Feb 2022 10:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=L4MqIEc/JbsQtnFnEaV173FD1GR2zeygOeGJKcIQHTM=; b=j/8rVgwYSLF3S4KclnS2WyxYGKq78Q2Pofky6B4ClrHiTlJMvAxQKPBPDGdnxYTHsb hWa5sLtrz+TbRfNlOWBc4U5GVLwtNNCOpckkzebNdjafWEgSepQR/Tx3PVA74hnePoYe xP/FJLDwab7dkTjeOQtTw4XYYbSSTdfn5l26SMVawmzCvxGn0PsUaQtrYTzTAf2eHRhv UHh/Fs9+sDwrPhDKZ8dAZ86rPtP+W71Tf2mhqhXbk+bdF02skbuCTWcGfkdJyOEd2qae vRIBLgSiv09yctbEh50CsDFVMftonFAzi5fVFFtJUei2H/ei/AK4uCh73Fj+BEMFRqMP WtEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=L4MqIEc/JbsQtnFnEaV173FD1GR2zeygOeGJKcIQHTM=; b=Z3weMugoWGa4mUXRDCMm9HqqD69jCUo98JTXXEx98CRjZtZwulekK1b7diW2qe584G yFliRQKU1m46ApjawooRMRLAcxU9Wy+ckbXG3elR37QFii67p4g+NDsA7fqfCFKeaEns s3hMvtCoe2hyPLHRpIN1m5GmM4OtGj4Gfj+UUSNuvObj32G3qPy33F+U/RNKLZMUViuO PWhpUwalbqUPMmbomnmZXWOalmBkCZJbjTbVc0LiptjxVh9RbsLk0YGl/x/AmwZTrDrB xfYwqOoTmGpWGXEJ1JfA0M849Pw62gtYzhnZWOf6EJ9TxC/9Znv56zzxd+RZV6BAeOQq gmFA== X-Gm-Message-State: AOAM532zfy9mCEt2Qv3bOgi8n9Js1z+WIqhm+a8bXGtX3CO/QIx6fvCs OvJiQUopbAt6rqxZ3DZGXTLMCz8BKFA= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a62:84d3:0:b0:4e1:b5c:1dd4 with SMTP id k202-20020a6284d3000000b004e10b5c1dd4mr8798283pfd.20.1645813381710; Fri, 25 Feb 2022 10:23:01 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 25 Feb 2022 18:22:48 +0000 In-Reply-To: <20220225182248.3812651-1-seanjc@google.com> Message-Id: <20220225182248.3812651-8-seanjc@google.com> Mime-Version: 1.0 References: <20220225182248.3812651-1-seanjc@google.com> X-Mailer: git-send-email 2.35.1.574.g5d30c73bfb-goog Subject: [PATCH v2 7/7] KVM: WARN if is_unsync_root() is called on a root without a shadow page From: Sean Christopherson To: Paolo Bonzini , Christian Borntraeger , Janosch Frank Cc: David Hildenbrand , Claudio Imbrenda , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Lai Jiangshan 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 WARN and bail if is_unsync_root() is passed a root for which there is no shadow page, i.e. is passed the physical address of one of the special roots, which do not have an associated shadow page. The current usage squeaks by without bug reports because neither kvm_mmu_sync_roots() nor kvm_mmu_sync_prev_roots() calls the helper with pae_root or pml4_root, and 5-level AMD CPUs are not generally available, i.e. no one can coerce KVM into calling is_unsync_root() on pml5_root. Note, this doesn't fix the mess with 5-level nNPT, it just (hopefully) prevents KVM from crashing. Cc: Lai Jiangshan Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 825996408465..3e7c8ad5bed9 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3634,6 +3634,14 @@ static bool is_unsync_root(hpa_t root) */ smp_rmb(); sp = to_shadow_page(root); + + /* + * PAE roots (somewhat arbitrarily) aren't backed by shadow pages, the + * PDPTEs for a given PAE root need to be synchronized individually. + */ + if (WARN_ON_ONCE(!sp)) + return false; + if (sp->unsync || sp->unsync_children) return true; -- 2.35.1.574.g5d30c73bfb-goog