From patchwork Mon Aug 18 20:30:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Schopp X-Patchwork-Id: 35538 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DEFBF20676 for ; Mon, 18 Aug 2014 20:36:39 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf47657611pab.8 for ; Mon, 18 Aug 2014 13:36:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:subject:references:in-reply-to:cc:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=j4m3N6W27rw0YyrwXq/J+Rxw1w6gMe04671fNrmjGu4=; b=IxtATEDfLwlNfFMRLkk40noGCP6/2REhfASCsy04F7M2nYy1WM1Sjm3C12JMPkR6/D CvMoEJ/Lvfhbh+Ib6OQYMEoeJVwPlCNY87Caqx34J3uehtB22IBqV53VKGlqB0wWZYiO JcJyQV4RGfyNe1JEo5VQBIj7SiQ1JwLbIotLZ7dmKuEhO/Nb1U1481od9SvkNhtQONpN ckeD0SAHdGoP4UnM0G8PhuYSU3IY/B/0Uz1+0Las+A8V25qvPlAEy/5HFYkqwfqxSG42 UQb0mVh9RZdf5CKCwBvsrDBpgt/7qilxEQqOOqn7H5mU/k5+cCUXu4XkzMvkaRkrlfFY YuIA== X-Gm-Message-State: ALoCoQkTsQkRa1+86/q52aqhWYfchH08YEAhIGumw5qqM04Qqkvpk+bMMKNNbQOLNc4PvhRIk0Cb X-Received: by 10.66.122.101 with SMTP id lr5mr19678234pab.19.1408394192697; Mon, 18 Aug 2014 13:36:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.176 with SMTP id t45ls2574504qgt.60.gmail; Mon, 18 Aug 2014 13:36:32 -0700 (PDT) X-Received: by 10.220.190.197 with SMTP id dj5mr26633250vcb.19.1408394192577; Mon, 18 Aug 2014 13:36:32 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id k19si3279323vdj.35.2014.08.18.13.36.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 Aug 2014 13:36:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id hq11so6452728vcb.30 for ; Mon, 18 Aug 2014 13:36:32 -0700 (PDT) X-Received: by 10.52.61.136 with SMTP id p8mr1919187vdr.15.1408394192263; Mon, 18 Aug 2014 13:36:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp183524vcb; Mon, 18 Aug 2014 13:36:31 -0700 (PDT) X-Received: by 10.66.161.169 with SMTP id xt9mr38584476pab.102.1408394191062; Mon, 18 Aug 2014 13:36:31 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id in13si23497277pac.129.2014.08.18.13.36.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Aug 2014 13:36:25 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJTcp-0000gV-UU; Mon, 18 Aug 2014 20:33:55 +0000 Received: from mail-bn1blp0184.outbound.protection.outlook.com ([207.46.163.184] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJTcl-0000co-KB for linux-arm-kernel@lists.infradead.org; Mon, 18 Aug 2014 20:33:52 +0000 Received: from BY1PR0201CA0028.namprd02.prod.outlook.com (25.160.191.166) by BY2PR02MB043.namprd02.prod.outlook.com (10.242.44.23) with Microsoft SMTP Server (TLS) id 15.0.1010.18; Mon, 18 Aug 2014 20:33:27 +0000 Received: from BN1BFFO11FD043.protection.gbl (2a01:111:f400:7c10::1:104) by BY1PR0201CA0028.outlook.office365.com (2a01:111:e400:4814::38) with Microsoft SMTP Server (TLS) id 15.0.1010.18 via Frontend Transport; Mon, 18 Aug 2014 20:33:26 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BN1BFFO11FD043.mail.protection.outlook.com (10.58.144.106) with Microsoft SMTP Server id 15.0.1010.11 via Frontend Transport; Mon, 18 Aug 2014 20:33:25 +0000 X-WSS-ID: 0NAIRRN-08-1IG-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 27CE1BD8903; Mon, 18 Aug 2014 15:33:22 -0500 (CDT) Received: from SATLEXDAG02.amd.com (10.181.40.5) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 18 Aug 2014 15:33:33 -0500 Received: from jdevbox.amd.com (10.180.168.240) by SATLEXDAG02.amd.com (10.181.40.5) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 18 Aug 2014 16:33:24 -0400 Message-ID: <53F26282.5010103@amd.com> Date: Mon, 18 Aug 2014 15:30:58 -0500 From: Joel Schopp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Christoffer Dall Subject: Re: [PATCH v4] arm64: fix VTTBR_BADDR_MASK References: <20140811203823.2828.36074.stgit@joelaarch64.amd.com> <20140812160521.GO10550@cbox> In-Reply-To: <20140812160521.GO10550@cbox> X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019005)(6009001)(428002)(189002)(199003)(23756003)(102836001)(81342001)(64126003)(74502001)(105586002)(107046002)(77096002)(101416001)(95666004)(33656002)(59896002)(81542001)(110136001)(106466001)(21056001)(79102001)(50466002)(36756003)(87936001)(31966008)(77982001)(85852003)(74662001)(64706001)(85306004)(83322001)(44976005)(83506001)(76482001)(53416004)(47776003)(80316001)(20776003)(4396001)(99396002)(83072002)(68736004)(19580395003)(87266999)(50986999)(65806001)(65816999)(92566001)(575784001)(65956001)(97736001)(84676001)(46102001)(54356999)(76176999)(92726001)(86362001)(80022001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR02MB043; H:atltwp02.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 03077579FF Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-OriginatorOrg: amd4.onmicrosoft.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140818_133351_874090_23D20F9A X-CRM114-Status: GOOD ( 11.77 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [207.46.163.184 listed in list.dnswl.org] -0.7 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [207.46.163.184 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record Cc: jungseoklee85@gmail.com, kvm@vger.kernel.org, Jungseok Lee , Sungjinn Chung , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: joel.schopp@amd.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 #endif /* __ARM_KVM_MMU_H__ */ second problem is that pgd is a virtual address, ie pgd == 0xfffffe03bbb40000 while the vttbr masks off the high bits for a physical address, ie vttbr_baddr_mask=0x00007ffffffe0000 . Even correcting for those issues I haven't been able to make this check work properly. I'll resend v5 the patch with all the other suggested changes. diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 16e7994..70f0f02 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -521,6 +521,7 @@ int create_hyp_io_mappings(void *from, void *to, phys_addr_t phys_addr) */ int kvm_alloc_stage2_pgd(struct kvm *kvm) { + unsigned int s2_pgds, s2_pgd_order; pgd_t *pgd; if (kvm->arch.pgd != NULL) { @@ -528,10 +529,18 @@ int kvm_alloc_stage2_pgd(struct kvm *kvm) return -EINVAL; } - pgd = (pgd_t *)__get_free_pages(GFP_KERNEL, S2_PGD_ORDER); + s2_pgds = (1 << (kvm_get_phys_addr_shift() - PGDIR_SHIFT)); + s2_pgd_order = get_order(s2_pgds * sizeof(pgd_t)); + + pgd = (pgd_t *)__get_free_pages(GFP_KERNEL, s2_pgd_order); if (!pgd) return -ENOMEM; + if ((unsigned long)pgd & ~vttbr_baddr_mask) { + kvm_err("Stage-2 pgd not correctly aligned: %p\n", pgd); + return -EFAULT; + } There are two problems that I've found here. The first problem is that vttbr_baddr_mask isn't allocated yet at this point in the code. The