Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1239527pxf; Fri, 2 Apr 2021 05:18:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJRJ03KByYtFj3g2Gg9eUnzyOVIsHdOjKlzFS43chuXIU5qllgZzcGiWcUqhBkvUOxPLCB X-Received: by 2002:a92:cb86:: with SMTP id z6mr10869798ilo.35.1617365880780; Fri, 02 Apr 2021 05:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617365880; cv=none; d=google.com; s=arc-20160816; b=0mLJTqIRkF3/V2+Q8JzPo0ao1oWoa0R6WtCktV/R0TnwJK1FyFBQ9tNzzyOJxYKWCq YO5H5Z4uq6F1zZOBXYmB8U8ewrAmPRxjtZBMcyq08BP9gsDqBGjUj4C8JRlbyu3w54FO wTcX/CoDoIigACuZaQ+wP5hPDUaFNgafiC6/kmcGv+mzCeCemHTameTMX5rWlQLMFHQ/ e0nx7Wavhc4axlFLcmpE03t1M9FsksJhGDcHggRlOHHmiBYgpjhGQ90YwWZCn12Q0AXy lz/Fz4gTzUsSAZsaC2E8ybrpjo2Sx1SRaCjXoSgwcrxsJfYgPneRXf2MEbwPIGF1rsPa GHcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=0jaEPxLaJfReD8pxSOXnANRrSayp5U1dcLmAQj7CP5E=; b=LvTL4x2RCMtL19hysnNGn6KnzVfFyO0epGKexJRRj4oDz4HBNvvecMmc6E2nBwDE38 9DNoRrH80HmD98YpZJkYDbHGg7POg9zYKeOIdKmKGx0gzWM8ApCkS3KpS3cDfDk4pZDF C7XqwN3MQeZr3/f11yj68P4+slF+KjKt99cX1XIQLW29Ico0yblh3vs/EhEHE7Qz34Y0 Y2UMa1xkb22WDRLV1oGvjWYa6usn22Ut9VA6zgz5UHEEAqSnIPOgkPnCFhoWmn4bNHZw 5mBVvETyy6wVnInQKy78iHc8NCBHjmX4GQHON2ytNMjI/40o7MXDInBOw3RumPuiMUYq PVkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b65z4Meu; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r6si7617610jak.28.2021.04.02.05.17.46; Fri, 02 Apr 2021 05:18:00 -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=@redhat.com header.s=mimecast20190719 header.b=b65z4Meu; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235351AbhDBMRK (ORCPT + 99 others); Fri, 2 Apr 2021 08:17:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37086 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235204AbhDBMRJ (ORCPT ); Fri, 2 Apr 2021 08:17:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617365827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0jaEPxLaJfReD8pxSOXnANRrSayp5U1dcLmAQj7CP5E=; b=b65z4Meu9/5m1HOQO/UQiMMM7gPtxy3UWh7exg5CfXIuAesEM3NVB7DNEBuNxIb168z2RW Yec+slbZqeL0276a0rcPT0d0A+AegmLEpdiLHZG4CpLs0IcECG5RVGnQaselS5CLWbpdFe Io4ruO+zfcoNU1MWszirwqDdtt+pOo4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-JItoow2QM461wIMIdOIiXQ-1; Fri, 02 Apr 2021 08:17:06 -0400 X-MC-Unique: JItoow2QM461wIMIdOIiXQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70CAA1005D57; Fri, 2 Apr 2021 12:17:05 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13D3F60BF1; Fri, 2 Apr 2021 12:17:05 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Ben Gardon Subject: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level Date: Fri, 2 Apr 2021 08:17:04 -0400 Message-Id: <20210402121704.3424115-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using manual protection of dirty pages, it is not necessary to protect nested page tables down to the 4K level; instead KVM can protect only hugepages in order to split them lazily, and delay write protection at 4K-granularity until KVM_CLEAR_DIRTY_LOG. This was overlooked in the TDP MMU, so do it there as well. Fixes: a6a0b05da9f37 ("kvm: x86/mmu: Support dirty logging for the TDP MMU") Cc: Ben Gardon Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index efb41f31e80a..0d92a269c5fa 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5538,7 +5538,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm, flush = slot_handle_level(kvm, memslot, slot_rmap_write_protect, start_level, KVM_MAX_HUGEPAGE_LEVEL, false); if (is_tdp_mmu_enabled(kvm)) - flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, PG_LEVEL_4K); + flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, start_level); write_unlock(&kvm->mmu_lock); /* -- 2.26.2