From patchwork Fri Dec 7 12:48:01 2018 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: 10718105 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 B6D281750 for ; Fri, 7 Dec 2018 12:57:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF062E006 for ; Fri, 7 Dec 2018 12:57:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FB2B2E01B; Fri, 7 Dec 2018 12:57:59 +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 C157E2E006 for ; Fri, 7 Dec 2018 12:57:58 +0000 (UTC) Received: (qmail 14281 invoked by uid 550); 7 Dec 2018 12:56:19 -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 Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 3158 invoked from network); 7 Dec 2018 12:49:38 -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=ZtGj2HHQ1QdQqkzxKnkhyG6zbN40ooJhtxiFxmtMZB2G6JXMbNVeLRlBclZc1ByuBt rJkGbokdWxQ0B4Z/lVF47mJXfpvZg6onuNs38evpR6F0plHgzidl0tnlt5rJTh3WpIX0 xXvr8J/Yp27UtUoFGtdUgpFJ6up0leTOytBXoBP3vyuv2whs8HO6r7g4e5dNAiOckiEq S4Jkfj+slyqpYESweAypsVAe8xa4+M+/i961soZgwCd01iqS8UtJC/jK7GFRWxJ15VKF iteVo2+659CaouRtxIESOgKb838vu10UoGWA0UJYtGjsBcL2ia6Cz6nFHafS5PeNz3tx ntcQ== 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=oTtsH99TPrH91S80YL3/cxaGg3O9sBd+jU0+lsozoHpFR1YCElaM1S74I5dSRWbnSj xPv9izvIF8mCkAj4iBKK73mmqG5Oo4HLZJdjsAiZUPsvZL4kNcHzdy09TtQ5b7m9qRWV y06WNxkAKCylANkKYV51PJw4zCJwMnPApu7zqoyT4CzgcZw6gnWLcgFdUHgfUSRziFO7 PpldihUNIH4bO96uYF3kVrj1Lb7nLoAo79GsUhpNXDk7JE84h3PCqCWy+3tVrRHj7Bln oqMKrasXlRctMkJ4qqQvdSD7yotG8FjnWBbvjzjGu/djpIZd7QruOkH1fWLxQfF4rZ/i uqLw== X-Gm-Message-State: AA+aEWbzEIpnKugAj5f3CNDlEtT8vZPmj2xn+HyXMzXbYLxHPwNmDTjf 1oUa+pAwXvrcRrpj41I5IHqg2g== X-Google-Smtp-Source: AFSGD/XycEJqUK3+cMbWlXGqoLuR+oFh9trApfppGt82EltYcdXfLPRSVVY6b30XONttXSMdK4nsLQ== X-Received: by 2002:adf:c846:: with SMTP id e6mr1624715wrh.243.1544186966936; Fri, 07 Dec 2018 04:49:26 -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: [PATCH 08/10] KVM: X86: Port ROE_MPROTECT_CHUNK to x86 Date: Fri, 7 Dec 2018 14:48:01 +0200 Message-Id: <20181207124803.10828-9-ahmedsoliman@mena.vt.edu> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207124803.10828-1-ahmedsoliman@mena.vt.edu> References: <20181207124803.10828-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;