From patchwork Sun Jan 20 23:39:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmed Abd El Mawgood X-Patchwork-Id: 10772535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E48F13BF for ; Sun, 20 Jan 2019 23:41:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D01C29CB1 for ; Sun, 20 Jan 2019 23:41:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D86C29CC0; Sun, 20 Jan 2019 23:41:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 9D54729CB1 for ; Sun, 20 Jan 2019 23:41:40 +0000 (UTC) Received: (qmail 27677 invoked by uid 550); 20 Jan 2019 23:41:25 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 26572 invoked from network); 20 Jan 2019 23:41:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mena-vt-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=juz3/8ubyO70o/WwTakdDVvsVYAiN+8d71XTlXhc8d0=; b=gnuyvR2bnuLilcd7+9IZF+J+o8w0XrNB/1Xkz7HCGSUq9qPW+NOUi/WjYSQqOIbFY6 zLE2d9gMubbXqFn/RyND6TvDIfdb/L+z0gY/VXI5CSIrtblIhzSkrwfO9Z3V+IZ3pvOf OgWoTmijDHQtTrwB5UKFvw62XDi3VPUnfQJz+ZgdTCd6RSzSyBC7iwapfZxpAHiNfiBX pBvS382M8jVHkBZVPVELstfsb3pvL6o7J+IpQFEUIL3qZGuiRXIiQ8eWV08tqCEpZ3k+ StfsIH+p6gK7RZjheXduzukbYDmmTJja/NEELPCmFu5nVOPQKZ38nUuJFdcfezgwc4gg o3Aw== 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=juz3/8ubyO70o/WwTakdDVvsVYAiN+8d71XTlXhc8d0=; b=CoGKnhZq+WGvXmwRSCay7GPK86I9xEbi/SJRcHpBHnK5f3b/lsC5pOlPrWZK7/EDy2 QBIN0Vd9J6FzWpQIiDO642Gk0Hads9a/e2oRObgUFoDY3Zp33/eS1cFKyfvzVkITnCwL 6aVMhQ4RHlrCltKI48RVvFWBLn6ADmY5ToBlG0DZyE+ghGvmdsgqGfbr/GG7jwDg0fsD pq6RkQMVgNW6h6TQBcqQuyzvwQMlMS01+YPI8yLtLq/tAeHUUGjS2rUMp1QqKybsnKxN JTVDLr7VY9X00ev4yRmIzoFi2aRCF3mII2ZiYKKBgaqN0d+t7bTgz7QiUMss3y3g0YFi zd9g== X-Gm-Message-State: AJcUukcSKQoBspBURygPfqwUVfXHorWyOnjyiK+YriDhZ83xXNh/J4Ff V2iMjYGi84BBKVMQpJGjABR5qg== X-Google-Smtp-Source: ALg8bN4jEjW9am+Xzj8QcDzzmQ0pxFo+cktjow7q+YKP8Hur7vhk7wc+PrdAJwB7Juu+8w+lON7BAA== X-Received: by 2002:a1c:2c6:: with SMTP id 189mr22057938wmc.21.1548027673915; Sun, 20 Jan 2019 15:41:13 -0800 (PST) From: Ahmed Abd El Mawgood To: Paolo Bonzini , rkrcmar@redhat.com, Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , hpa@zytor.com, x86@kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, ahmedsoliman0x666@gmail.com, ovich00@gmail.com, kernel-hardening@lists.openwall.com, nigel.edwards@hpe.com, Boris Lukashev , Igor Stoppa Cc: Ahmed Abd El Mawgood Subject: [RESEND PATCH V8 03/11] KVM: X86: Add helper function to convert SPTE to GFN Date: Mon, 21 Jan 2019 01:39:32 +0200 Message-Id: <20190120233940.15282-4-ahmedsoliman@mena.vt.edu> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190120233940.15282-1-ahmedsoliman@mena.vt.edu> References: <20190120233940.15282-1-ahmedsoliman@mena.vt.edu> MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ahmed Abd El Mawgood --- arch/x86/kvm/mmu.c | 7 +++++++ arch/x86/kvm/mmu.h | 1 + 2 files changed, 8 insertions(+) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 098df7d135..bbfe3f2863 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1053,6 +1053,13 @@ static gfn_t kvm_mmu_page_get_gfn(struct kvm_mmu_page *sp, int index) return sp->gfn + (index << ((sp->role.level - 1) * PT64_LEVEL_BITS)); } +gfn_t spte_to_gfn(u64 *spte) +{ + struct kvm_mmu_page *sp; + + sp = page_header(__pa(spte)); + return kvm_mmu_page_get_gfn(sp, spte - sp->spt); +} static void kvm_mmu_page_set_gfn(struct kvm_mmu_page *sp, int index, gfn_t gfn) { diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index c7b333147c..49d7f2f002 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -211,4 +211,5 @@ void kvm_mmu_gfn_allow_lpage(struct kvm_memory_slot *slot, gfn_t gfn); bool kvm_mmu_slot_gfn_write_protect(struct kvm *kvm, struct kvm_memory_slot *slot, u64 gfn); int kvm_arch_write_log_dirty(struct kvm_vcpu *vcpu); +gfn_t spte_to_gfn(u64 *sptep); #endif