Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2320329pxu; Mon, 7 Dec 2020 03:39:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnNRCyfp4tPFkCAKEvIVvylYOGIp3giih0zwBG8H5Sa6IibAETgGGHwM9NKBboDoBOPgok X-Received: by 2002:aa7:dc4b:: with SMTP id g11mr20109868edu.379.1607341144562; Mon, 07 Dec 2020 03:39:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607341144; cv=none; d=google.com; s=arc-20160816; b=m919rkUZaRxUdntjFz9mGUmYC/o+bX+nrtk5omgMnrwFTaMm5mGRk5tSKJERQOuP5i 9lS220rhR0gOVpqTPentmAAE9M8imJbn/GnFnJCvcu5FysJKMqHKHu2XTXT7EbTqCMJt 0UAlskd2pYauJA/CfKB0Gf5h539hNDjZOH3hnVUQi1wtvG5DtUdll9UVFsyD6cbI2nIV zfj/oDhobCqWV7kkmhVCJr9fB7yBSKk2/6J9e7lNteybNrBydLHqfgUxY0UScv9qJdFl 7TBBfFcxMdq6/my8K0Pj8EXTNeRP5jt+k8XV6pPMIHajraHmHwRy55angFrHqKBD43AD BF6A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ve50LBxe7KPsa/afhSPdadx4mGbx0d5NNuSu5BfW+ws=; b=m8PwR/ZOUYGoHmBURNpPtu3+6T1kIT47KHy8phn5FAGR+RhzIxeQImEun/wDEx2oNT 1t9RaKuvS3q3qUlXNi4qbOWF4Z8vYyV3XxZkaKGUBYgA1xAi18Losbl1ovDneC7n8NW/ q5x3tm0/zQNH9+ovL2EOjMUI1qSWXhAQv6h+CyS1ew21tclvl9c68RR8QwpQ4jx4kqgq g375dWsbGrMQsWdxyR59PwzSapMtb5UBFUjkY4E0KFIxtdjbNOkE3uEDONbS/CIALE5v zhhZNVJblrWEhNxYjEjdFLaZ+EAb55UQ1Tazjtk7kyWC0D/sQPPlc1BriBcO8VJAkjLo +x+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iGPfYHDT; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp1si6503405ejc.21.2020.12.07.03.38.41; Mon, 07 Dec 2020 03:39:04 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=iGPfYHDT; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727658AbgLGLgP (ORCPT + 99 others); Mon, 7 Dec 2020 06:36:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727496AbgLGLgM (ORCPT ); Mon, 7 Dec 2020 06:36:12 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B869C061A51; Mon, 7 Dec 2020 03:35:32 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id iq13so7183740pjb.3; Mon, 07 Dec 2020 03:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ve50LBxe7KPsa/afhSPdadx4mGbx0d5NNuSu5BfW+ws=; b=iGPfYHDT9qrLj7NFYNDa99CfU/LeTtf1xtrQ4M7/y/WnH1dn41NqjJOU3FG2cI2rI1 h0kfX9f8shUAZZMOJgGaejDmBdM+kopryJtCrKgU0WydjatlKrXuJdW2bF7peb3YE73w HuxE6iS0CuXe4q7GR4g4kSkSH6FnTepRTIMRjxotGxhIeEy3ukOJoI5oZIXRy7bWfhgi IvKePLSYBnWHUrmlhAUkfkx96TSLs4I/L6WgpPAkzxznqxqFcO+gGTdsC/FaANWeyvGZ qVOLpBLEzfoJSjxHnOcThPOkYd3adliwtBA5VZ8npQ1fRXKU/uPKqTcL3sx4i7jwqU37 jGTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ve50LBxe7KPsa/afhSPdadx4mGbx0d5NNuSu5BfW+ws=; b=cu5oQ2xVkvv8YjCyvP/SECkAXF9FTuwciqkIffybDTP7CgTmT21VdALgVFrLa3L1Y9 UyCsmwIP+3eUi6Kbprk/6JM63sl7EFNzi4PgiktwBGK4NMa4sMauea/u8cFz9i5ciGKi EkKzSmya2jVX0k0g3HvxI7J+op17lHb2xG8I5wBvSgqxF3Bbyw9B6kzvmAN8rtOjnepZ cprWdf/dXskV2vo5oCfcH6gcJTG1K7DBFHPff8k/CyTCaEeY8TxWbr5z0ZnECGPyI/ie nrr0NqTV1q+7yxhOrWlYYWU7cFfoBsmAnaIHDUiOF24HJCOidOsvSGDzkXHUnFa1OtMi fPlQ== X-Gm-Message-State: AOAM532+lmkxrzAJ2ckvxqTPoMJz4PDIsTPycr1DPMnwHubielLibSqc LlcuUBZODobbQbMZw1pte7WtD0IsvP4= X-Received: by 2002:a17:90b:1945:: with SMTP id nk5mr15957725pjb.30.1607340931753; Mon, 07 Dec 2020 03:35:31 -0800 (PST) Received: from localhost.localdomain ([203.205.141.39]) by smtp.gmail.com with ESMTPSA id d4sm14219822pfo.127.2020.12.07.03.35.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2020 03:35:31 -0800 (PST) From: yulei.kernel@gmail.com X-Google-Original-From: yuleixzhang@tencent.com To: linux-mm@kvack.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, naoya.horiguchi@nec.com, viro@zeniv.linux.org.uk, pbonzini@redhat.com Cc: joao.m.martins@oracle.com, rdunlap@infradead.org, sean.j.christopherson@intel.com, xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang Subject: [RFC V2 33/37] kvm, x86: enable record_steal_time for dmem Date: Mon, 7 Dec 2020 19:31:26 +0800 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yulei Zhang Adjust the kvm_map_gfn while using dmemfs to enable record_steal_time when entering the guest. Signed-off-by: Yulei Zhang --- virt/kvm/kvm_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 2541a17..500b170 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -2164,7 +2165,10 @@ static int __kvm_map_gfn(struct kvm_memslots *slots, gfn_t gfn, hva = kmap(page); #ifdef CONFIG_HAS_IOMEM } else if (!atomic) { - hva = memremap(pfn_to_hpa(pfn), PAGE_SIZE, MEMREMAP_WB); + if (is_dmem_pfn(pfn)) + hva = __va(PFN_PHYS(pfn)); + else + hva = memremap(pfn_to_hpa(pfn), PAGE_SIZE, MEMREMAP_WB); } else { return -EINVAL; #endif @@ -2214,9 +2218,10 @@ static void __kvm_unmap_gfn(struct kvm_memory_slot *memslot, kunmap(map->page); } #ifdef CONFIG_HAS_IOMEM - else if (!atomic) - memunmap(map->hva); - else + else if (!atomic) { + if (!is_dmem_pfn(map->pfn)) + memunmap(map->hva); + } else WARN_ONCE(1, "Unexpected unmapping in atomic context"); #endif -- 1.8.3.1