Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp605320pxb; Wed, 3 Nov 2021 09:19:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy8RRyB9OAQs5wuVzEujr79PlARHy9pDwsAbfNZKQce/27Z6XzN5+FMstwJOtfcrOlCVur X-Received: by 2002:a05:6638:3488:: with SMTP id t8mr11501573jal.14.1635956393393; Wed, 03 Nov 2021 09:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635956393; cv=none; d=google.com; s=arc-20160816; b=mSrODuwt/WQv62hl7rHNAmhJ21SW281ODmkgg/aKwev5ngdmafnrgjTlkUGqfqdcp0 z9AD57sRmXjXGWUCDqvj4T8aP23xELvMs6taDbr/YmhRQFrosIHKM6ZKpinMkcjVWCUj T7WypjZHLjILmeMcScBICm5/uLZLAZ6HUqVAzxeeRJJkQxZl2NZdZv0aMkZI515lsRZT agVuNqvyEc8BVgbr+m7g3PUvmAZ0f6p65fzyy0uDPNu+J8XoxY8BrjYa5f9qAFZSXWIN TFeCc4M1vPaJdceG6nEubPPaqBz2sYDryIHs48nDSUZBT+0QYkXt0hCBIpS2alSygkZw Yqyw== 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:mime-version:message-id:date :reply-to:dkim-signature; bh=eD9dW/j7qWODztQefqhaj/ToXeE3Wj/nmDQbWVvMxKk=; b=jHD+d57ZCLXvxWnWuAKnDBUsN29y7FxQUIYUZJvjcDjABozV/Lyth6s0+4b887KDFs Ul54szhzyI39mofVvYuIYFtCB906hM0q+t3KF0fuXHQsgCAA1A3YyH9gqSoSYYMRwoBu nvxofS/cffPIh5wHb3LJnWi303e5ow6EIjwnFrEnFUvRwCuAz9JwL1JGMYx0nC0RbfW6 pgvsiFuy+T4O4riokLXGx7BfeuNV+sz7sAjsZtZHRncl6kUf1lgnPCHch3QilTxdZw5w c/T1q6iSlz7mr0WDhuw2ISUxOlQzNh2Mh6JkQvVdCHLgV41e4hzifZOIxdToMYMRPue4 u98Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=B7Tuyg6F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si3372994ior.11.2021.11.03.09.19.40; Wed, 03 Nov 2021 09:19:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=B7Tuyg6F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232721AbhKCQVP (ORCPT + 99 others); Wed, 3 Nov 2021 12:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbhKCQVO (ORCPT ); Wed, 3 Nov 2021 12:21:14 -0400 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 80C27C061714 for ; Wed, 3 Nov 2021 09:18:37 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id q7-20020a25b007000000b005c1d1377abdso4518152ybf.23 for ; Wed, 03 Nov 2021 09:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:message-id:mime-version:subject:from:to:cc; bh=eD9dW/j7qWODztQefqhaj/ToXeE3Wj/nmDQbWVvMxKk=; b=B7Tuyg6FcQjL73pK9DX41IC4JAWwExMKgucji0qg2qjeczLxUp2CqLYXrZvtjFGdBT 9U1MeUl7T5LeunTuiPha8fNH/D7LkXVMJkCYXYerQRPnEGobJrzvN1E9qVLrXT6K9jIi GfsJbk0YI9inqzgSD/fABK+2I/RLQ0jhjvpB21M/7jOSoEg98GTB0WYtQtLTTa3l5zle CJ/XX4fZdpfd915ZBeqxyPM9YNhI0P4vrI7pxhdZfowe84rrA0uhzHhkK9BzCkC1B/vq Yu4eGUx3D2mf6guZzhRBf+S1PsFUY+8cdKAihax7iSPWUFkQ4FPUSqA90SKJPGMNwAn5 20yQ== 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:message-id:mime-version:subject :from:to:cc; bh=eD9dW/j7qWODztQefqhaj/ToXeE3Wj/nmDQbWVvMxKk=; b=TVBKsDFtWENFruT5mv70BUYKrX96dVQwh4lHTCyl8fZptsMQtl1yiOLhEjkwDbqL1X 0EtMP7UuGKWOUM1vplurtXXdnchshbDcZmXuydGV/PcQFK2DqJjDF2JnKR+2zxtVrh3O B3s7+lXB7jcaMzqv56oN5xRzOPvXcmNllYdaPyKUBCIUUAGg8xcHwgVW7/9NkfzwdzUd ORk+wiTKIXQwpECO8Dq4u3ppfd2eB8zrTQEdFEqdLGSt1lL8X7wNCNLTsDdHlnudDFWG kfWk3/HMXFpN3L420CmU/vt8MEGcojzoDela7TP7bdxJy0K7Tj3EYfCDt1H4LBQrofyo B8CQ== X-Gm-Message-State: AOAM531OQaXNCxcagqDESE25bj8LOWd1bCpdMu8l61sQwC2GFCxMb1is Cm8Z5F1ISmyNYhSgOYPsERjsgX5KJ4E= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:e8d5:d0cd:12fd:266e]) (user=seanjc job=sendgmr) by 2002:a25:d15:: with SMTP id 21mr27811929ybn.141.1635956316718; Wed, 03 Nov 2021 09:18:36 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 3 Nov 2021 09:18:33 -0700 Message-Id: <20211103161833.3769487-1-seanjc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog Subject: [PATCH] KVM: x86/mmu: Properly dereference rcu-protected TDP MMU sptep iterator From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wrap the read of iter->sptep in tdp_mmu_map_handle_target_level() with rcu_dereference(). Shadow pages in the TDP MMU, and thus their SPTEs, are protected by rcu. This fixes a Sparse warning at tdp_mmu.c:900:51: warning: incorrect type in argument 1 (different address spaces) expected unsigned long long [usertype] *sptep got unsigned long long [noderef] [usertype] __rcu *[usertype] sptep Fixes: 7158bee4b475 ("KVM: MMU: pass kvm_mmu_page struct to make_spte") Cc: Ben Gardon Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/tdp_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index 7c5dd83e52de..a54c3491af42 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -897,7 +897,7 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault, struct tdp_iter *iter) { - struct kvm_mmu_page *sp = sptep_to_sp(iter->sptep); + struct kvm_mmu_page *sp = sptep_to_sp(rcu_dereference(iter->sptep)); u64 new_spte; int ret = RET_PF_FIXED; bool wrprot = false; -- 2.33.1.1089.g2158813163f-goog