From patchwork Sun Nov 4 17:11:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ahmed Soliman X-Patchwork-Id: 10666961 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 0142A13A4 for ; Sun, 4 Nov 2018 17:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC370289F4 for ; Sun, 4 Nov 2018 17:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDD4228A57; Sun, 4 Nov 2018 17:13:44 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 19E8F289F4 for ; Sun, 4 Nov 2018 17:13:43 +0000 (UTC) Received: (qmail 32339 invoked by uid 550); 4 Nov 2018 17:12:45 -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 32284 invoked from network); 4 Nov 2018 17:12:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=DwaIjaOplxzcZ7ftx2a6kgsWPHMYRimWe+wNdR5/hJE=; b=MhkdCSshEjRNx9P6uI8UFpbF8xhZBi+BXrVUGq0azBHVfb+d1zjeBVZE0MZmNYcXRY MA6om+WJgl40o+v+zhnVpCAqEXp+JlmQvMJ4Xsll1pSAkOtANQ6qWh/Q+ckP7nV1hXa6 CqzPOGiKXUiwojtMSBT3idTVZQFRgNoqAw4wZ8VeT65adKtmaINQAET4gwQnH/RF30w3 f+cnlNNaERkdOCwvSvDkYWwImy5CnYaVJmX6iV8E9cqT+RePOhDQZSqKCdVOQeHKWsQn AngBM2mt/BjtcyGnUowd/4FXyQ+gF42PKnufo74QdGHHdrfViUkkkv9gWRhFm4I0zBtW 4GyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=DwaIjaOplxzcZ7ftx2a6kgsWPHMYRimWe+wNdR5/hJE=; b=JZPvN/WOmp90WV2U8nEPpOAACAbjg5zKq/yeYeh9yWw7j7bleGqapOMCuPiSdKI2t7 l69+IVl9BTwXA5LgShdiXW4LH14vzuJ5eMbh9GtOWP5AsbDb/er1bBZVClzqW8Wg6wud KqFEUtoDizR1ZtXcj2i5uOxc+6f6cMDDziqCDmBgwczF30mKOhmh8SRKu1UOMEhVSEK+ T13rtyUzT4l1i5ECztg1sQjCYwoaHoUiadNmnCFTh6XWWL+50UPhiVBtc8e31ioN3fME aSExdSu7Zuftl00RSCAyd13z+8lmw+CDNSo7844TjCa3qoJbmwJFdGLt70pq6bW7j9v+ qNjw== X-Gm-Message-State: AGRZ1gKHjXJKLc7UN0GMXsSBm0dRFxFFjyEmLCB0MVyvYrZskRCKs4bS ABvueyyFY88DImjN7gpSPs8= X-Google-Smtp-Source: AJdET5e89ZUGWapFPY6etHj5e1LT86pqcOptFq7O4qxay+gQJ0F3xdZD6d3MGP1AJX6TZZjit4uaxQ== X-Received: by 2002:adf:f148:: with SMTP id y8-v6mr4983695wro.303.1541351553120; Sun, 04 Nov 2018 09:12:33 -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 , Hossam Hassan <7ossam9063@gmail.com>, "Ahmed Lotfy igor . stoppa @ gmail . com" Subject: [PATCH V6 7/8] KVM: X86: Port ROE_MPROTECT_CHUNK to x86 Date: Sun, 4 Nov 2018 19:11:23 +0200 Message-Id: <20181104171124.5717-8-ahmedsoliman0x666@gmail.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20181104171124.5717-1-ahmedsoliman0x666@gmail.com> References: <20181104171124.5717-1-ahmedsoliman0x666@gmail.com> 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 cd3e6944c15f..b2b50fbcd598 100644 --- a/arch/x86/kvm/roe.c +++ b/arch/x86/kvm/roe.c @@ -25,9 +25,12 @@ static bool __rmap_write_protect_roe(struct kvm *kvm, struct rmap_iterator iter; bool prot; bool flush = false; + void *full_bmp = d->memslot->roe_bitmap; + void *part_bmp = d->memslot->partial_roe_bitmap; for_each_rmap_spte(rmap_head, &iter, sptep) { - prot = !test_bit(d->i, d->memslot->roe_bitmap) && pt_protect; + prot = !(test_bit(d->i, full_bmp) || test_bit(d->i, part_bmp)); + prot = prot && pt_protect; flush |= spte_write_protect(sptep, prot); d->i++; }