From patchwork Sun Jan 20 23:39:37 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: 10772545 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 DB83F13BF for ; Sun, 20 Jan 2019 23:42:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB12729CB1 for ; Sun, 20 Jan 2019 23:42:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEE5B29CC0; Sun, 20 Jan 2019 23:42:38 +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 D73B529CB1 for ; Sun, 20 Jan 2019 23:42:37 +0000 (UTC) Received: (qmail 30295 invoked by uid 550); 20 Jan 2019 23:41:43 -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 30209 invoked from network); 20 Jan 2019 23:41:43 -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=ibxTSM7aAfMxp0mh34e5XoCF9bu27Z34+6gCZTrPT34=; b=lcJa/9GoZ/Y6WfC0bylBfI5oCVTUbuuQaazcglM7FxSXk53oJ3EwA7gQ6DK+WxiFMb Tlrgwvc736fHcfg+YAswmtczDWnSSBMIcGSSXYg6i0MRH/ZIX2y9cpGSxmZ+J63hsT4/ QTQXtg0gQ8OgWOCw2BrEXgDSkegRbpVoC0R+6nlx8MG5HL4zfx/R+JZ6gMYPKE+l1tLJ AXI8c4Qwl9aiXZE+hXoOGirioCNsW/YzcD/4+02Q9kHE3d1EMNxtT20zPoj7Mcuv0039 pK40Sk4UGAAo1eF1IXEqWJ3/lN+mYFSzRQBsmUcXjgxuNNvUwayW8QCEFaj6ijFFXHa+ HtKQ== 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=ibxTSM7aAfMxp0mh34e5XoCF9bu27Z34+6gCZTrPT34=; b=p4HlvkB05UIOe+3Pgq0Hz38tLD4KPgooMZttLc+605VlZWYIyFbr9Y6jNiqE5IEM3L 5MhUF8d68GiDssMdp6VlzBwyDCfYcgU7or/D2wmmv7ZLUHeiJlZ3HXf0GsdCSxq1Sed+ qL66sfk6XFN1nSG3+TbC8dSzSS/Z4rkytxg0Fhl1rvpOEADf5UhNw01ALP5w/wr3aLnj Uo7ELIt59uunyWeTvKUMSOm9PWZyLOm3XMrHBrgf0MUE1mBVDPqKFwwIGzWOctStoSZT BvQDZbv2z1gDjBzUTwVrz3w8WHELyCnIta5IFtsjcnzeMMpQNd/JshppewsRXRm2Sa58 4E8A== X-Gm-Message-State: AJcUukfpH03jnS5S8TFeY96vSPg/zEdBdY6piCcf9GXXvHbQadsaXVWo 4Ha18pcgtf1WQ+d/TKrQgn4F5g== X-Google-Smtp-Source: ALg8bN6p9RWZDpkENLmzoXwCtF9v6nAyN1W721G5G6yv2ozcu7srm3C8FwlQtG+MKjShLdYSf4N48A== X-Received: by 2002:a1c:9a4c:: with SMTP id c73mr23491864wme.35.1548027691743; Sun, 20 Jan 2019 15:41:31 -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 08/11] KVM: X86: Port ROE_MPROTECT_CHUNK to x86 Date: Mon, 21 Jan 2019 01:39:37 +0200 Message-Id: <20190120233940.15282-9-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 Apply d->memslot->partial_roe_bitmap to shadow page table entries too. Signed-off-by: Ahmed Abd El Mawgood --- arch/x86/kvm/roe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/roe.c b/arch/x86/kvm/roe.c index f787106be8..700f69823b 100644 --- a/arch/x86/kvm/roe.c +++ b/arch/x86/kvm/roe.c @@ -25,11 +25,14 @@ static bool __rmap_write_protect_roe(struct kvm *kvm, struct rmap_iterator iter; bool prot; bool flush = false; + void *full_bmp = memslot->roe_bitmap; + void *part_bmp = memslot->partial_roe_bitmap; for_each_rmap_spte(rmap_head, &iter, sptep) { int idx = spte_to_gfn(sptep) - memslot->base_gfn; - prot = !test_bit(idx, memslot->roe_bitmap) && pt_protect; + prot = !(test_bit(idx, full_bmp) || test_bit(idx, part_bmp)); + prot = prot && pt_protect; flush |= spte_write_protect(sptep, prot); } return flush;