From patchwork Mon Dec 7 11:31:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yulei zhang X-Patchwork-Id: 11955447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94A45C433FE for ; Mon, 7 Dec 2020 11:34:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2611723340 for ; Mon, 7 Dec 2020 11:34:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2611723340 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ABB988D0015; Mon, 7 Dec 2020 06:34:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A6D6E8D0001; Mon, 7 Dec 2020 06:34:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 981798D0015; Mon, 7 Dec 2020 06:34:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0175.hostedemail.com [216.40.44.175]) by kanga.kvack.org (Postfix) with ESMTP id 81C9B8D0001 for ; Mon, 7 Dec 2020 06:34:56 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 53C208249980 for ; Mon, 7 Dec 2020 11:34:56 +0000 (UTC) X-FDA: 77566279392.20.pig76_1f03bdb273de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 362C5180C0609 for ; Mon, 7 Dec 2020 11:34:56 +0000 (UTC) X-HE-Tag: pig76_1f03bdb273de X-Filterd-Recvd-Size: 5107 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Dec 2020 11:34:55 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id i3so6029677pfd.6 for ; Mon, 07 Dec 2020 03:34:55 -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=cfW0rkOgMIuxNIUMjXUU1M20WeHJvF5wHx5SDbaa7WE=; b=tAKAgseG2CCONQ+JBLfVPuz/DEVm6e6uJwCvBS1RREKrlZrlOUdzYsuLEUhueHfOFF uFV+57rP3yHKObWXA15tn3JY9Y2Mp7P0iPIKN8JWG9DeMFVnD03wWM3MnRRZiJQT6AF2 WR2vxkVxf0MNXxhaYUqnCBkgNMZXajnPprZpauiW0v4cZtIPknD9A9IWTbwA3N/nERtu oiMqPUyiyheuzpFUWKvr/tZb1S1TJE2PoPMHS+zlAU086PYQuSRhzWuPFYiB7b1Acfcl yxBbTTVnn5ROFZOGNlweU2k6Hu7UN+pZY6i4XQztkumh8Gv00oB9pvKIHKFEHgAYZYi/ 4JrQ== 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=cfW0rkOgMIuxNIUMjXUU1M20WeHJvF5wHx5SDbaa7WE=; b=Eka/OnV0MgWE6COGv5rHlyVe6DwKE+7fI3X9ulq4f2GAVG2UthMoX4FZDxGrWQusr5 r9eMmckaynEM+DAA4MccvE4zL9J2ffI3Fzrt7tZuVjhitvB7lyZKnt5320Vj3ldeGf1F fwLdALbnmrF2FpBO99E3uOQHTEFszNYHnOUDHLgVt1UP4j2AeAnV1bdhLyIFv/2GsBiY BtZdaPJweHawwW9eQnzYrbPnmIzlvEXubcFZq5fyNkLEQojlYw/UowC30cM1OqQXuYpq 95yY14Bw+JOuxswdeu8KXRgvxk0o3HSTy8bB1RV3m103ZWp0TCjwqAgjiBfYyx7zLkhB ZK6Q== X-Gm-Message-State: AOAM532tLLlAAH4MrbLaPhzNzFm0Q1sVX/WyTHe/u6cShnxpvydu0ZXx +VrY3pWpYz7nAtWe11pu9PbUOMS7nPc= X-Google-Smtp-Source: ABdhPJwFz1981DhHI3jR9VGpOCOSaq+Ig5CXILTKJ1ERZg74A7VBmwCCkjGQ9zkn+U6XHw4ztmn59g== X-Received: by 2002:a17:902:5581:b029:da:a817:1753 with SMTP id g1-20020a1709025581b02900daa8171753mr15580441pli.76.1607340894707; Mon, 07 Dec 2020 03:34:54 -0800 (PST) Received: from localhost.localdomain ([203.205.141.39]) by smtp.gmail.com with ESMTPSA id d4sm14219822pfo.127.2020.12.07.03.34.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2020 03:34:54 -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 , Chen Zhuo Subject: [RFC V2 22/37] kvm, x86: Distinguish dmemfs page from mmio page Date: Mon, 7 Dec 2020 19:31:15 +0800 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Yulei Zhang Dmem page is pfn invalid but not mmio, introduce API is_dmem_pfn() to distinguish that. Signed-off-by: Chen Zhuo Signed-off-by: Yulei Zhang --- arch/x86/kvm/mmu/mmu.c | 1 + include/linux/dmem.h | 7 +++++++ mm/dmem.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 5bb1939..394508f 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include diff --git a/include/linux/dmem.h b/include/linux/dmem.h index 8682d63..59d3ef14 100644 --- a/include/linux/dmem.h +++ b/include/linux/dmem.h @@ -19,11 +19,18 @@ unsigned int try_max, unsigned int *result_nr); void dmem_free_pages(phys_addr_t addr, unsigned int dpages_nr); +bool is_dmem_pfn(unsigned long pfn); #define dmem_free_page(addr) dmem_free_pages(addr, 1) #else static inline int dmem_reserve_init(void) { return 0; } + +static inline bool is_dmem_pfn(unsigned long pfn) +{ + return 0; +} + #endif #endif /* _LINUX_DMEM_H */ diff --git a/mm/dmem.c b/mm/dmem.c index 2e61dbd..eb6df70 100644 --- a/mm/dmem.c +++ b/mm/dmem.c @@ -972,3 +972,10 @@ void dmem_free_pages(phys_addr_t addr, unsigned int dpages_nr) } EXPORT_SYMBOL(dmem_free_pages); +bool is_dmem_pfn(unsigned long pfn) +{ + struct dmem_node *dnode; + + return !!find_dmem_region(__pfn_to_phys(pfn), &dnode); +} +EXPORT_SYMBOL(is_dmem_pfn);