From patchwork Fri Dec 21 03:28:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10739843 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 C015513A4 for ; Fri, 21 Dec 2018 03:29:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1FBC286BE for ; Fri, 21 Dec 2018 03:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A66C7287A3; Fri, 21 Dec 2018 03:29:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64F8628761 for ; Fri, 21 Dec 2018 03:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388947AbeLUD3E (ORCPT ); Thu, 20 Dec 2018 22:29:04 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36170 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388804AbeLUD3E (ORCPT ); Thu, 20 Dec 2018 22:29:04 -0500 Received: by mail-pg1-f193.google.com with SMTP id n2so1839095pgm.3; Thu, 20 Dec 2018 19:29:03 -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; bh=w7YJeoI7nH650ZmWvJmAoGR4DrRCx/VmvknpfY9MjlY=; b=px65DBlkwhu8P1y3n2Rg2GmJAfSCbdQ/C6ZfXMdYD0nEaUJJVXv1S/AGyvKuiRwUao cyA5LqlBWYTxmtC5PaUhWDUC0AgB2PDPlRwhCpuH1NSEXLmT6OkVth/dI18R08OHsS8o YBbfnvmpLg/DJO8CgTxl1VZSr6djbZaJkMAwKRz4viA/NNTUeCkv7SCNwYruc1+q760G qlPMiXQFrUufQ2Kq/VfYtFccdAu687c7kX3VgH/wcx9qANRjVDDVSeA0P6n7OJaweIMG sSN6F5J1weHipvWJQlfE8uGPIX44Dsfkw2sU1XLUHWvJ4eJ+cGBcP5FqD5U5kOt6rChA eHTg== 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; bh=w7YJeoI7nH650ZmWvJmAoGR4DrRCx/VmvknpfY9MjlY=; b=lCVNNclDUCJe2qCsu005Y8N3mJp2v8gROaH6oQ2fUL0RiBU97ZgdYUWcZw22sPJy4W oAI1n3bHJnNQR4MejLT8c3Oit8uCyypzQuwe9VlN1xCASN0CspXrhx1hzN42muY93TUH 1slwHme/9UmNcApxMMO/lJd+YMWUin/hQ/5mmnKpG3TiuGFQhxpm19M3cJp/TFB2UmtK iwDXusBVVdW5+7o2xjjyfEr3x/yZfkX1SQcJgTWbmM3IA8SxuN71kD404QZ8H+M949a/ fz6mHYlXwn3ZgAvsJd764tJazi8DBndldEDlSSZigz2iLeRFirbiWFkL3aQDPPsAX5v8 JlaQ== X-Gm-Message-State: AJcUukcSSLSg9WiwWPkO+gbMAI7dcPv/ETYVa4rBiy9I73r+fAquDZjf TQG+QDsqa1cSBjZkc9PgNdMJKnH0 X-Google-Smtp-Source: AFSGD/V128uBaAmm6DLh+Q01MoDS+t/9ObZX1HocbY0qHMlVKRaPC5yDV/CcSowqIxLVuYBk/ngzHQ== X-Received: by 2002:a62:4549:: with SMTP id s70mr802621pfa.233.1545362943377; Thu, 20 Dec 2018 19:29:03 -0800 (PST) Received: from surajjs2.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id n68sm33062582pfb.62.2018.12.20.19.28.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 19:29:02 -0800 (PST) From: Suraj Jitindar Singh To: kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, paulus@ozlabs.org, david@gibson.dropbear.id.au, mdroth@linux.vnet.ibm.com, Suraj Jitindar Singh Subject: [PATCH 2/5] KVM: PPC: Book3S HV: Align gfn to L1 page size when inserting nest-rmap entry Date: Fri, 21 Dec 2018 14:28:40 +1100 Message-Id: <20181221032843.13012-3-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181221032843.13012-1-sjitindarsingh@gmail.com> References: <20181221032843.13012-1-sjitindarsingh@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Nested rmap entries are used to store the translation from L1 gpa to L2 gpa when entries are inserted into the shadow (nested) page tables. This rmap list is located by indexing the rmap array in the memslot by L1 gfn. When we come to search for these entries we only know the L1 page size (which could be PAGE_SIZE, 2M or a 1G page) and so can only select a gfn aligned to that size. This means that when we insert the entry, so we can find it later, we need to align the gfn we use to select the rmap list in which to insert the entry to L1 page size as well. By not doing this we were missing nested rmap entries when modifying L1 ptes which were for a page also passed through to an L2 guest. Signed-off-by: Suraj Jitindar Singh Reviewed-by: David Gibson --- arch/powerpc/kvm/book3s_hv_nested.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c index 0dfbf093bde5..9dfb927ea14f 100644 --- a/arch/powerpc/kvm/book3s_hv_nested.c +++ b/arch/powerpc/kvm/book3s_hv_nested.c @@ -1226,6 +1226,8 @@ static long int __kvmhv_nested_page_fault(struct kvm_vcpu *vcpu, return ret; shift = kvmppc_radix_level_to_shift(level); } + /* Align gfn to the start of the page */ + gfn = (gpa & ~((1UL << shift) - 1)) >> PAGE_SHIFT; /* 3. Compute the pte we need to insert for nest_gpa -> host r_addr */