From patchwork Fri Sep 12 13:16:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 4894751 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9FE689F32F for ; Fri, 12 Sep 2014 13:11:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C38F32026D for ; Fri, 12 Sep 2014 13:16:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 062A3202F2 for ; Fri, 12 Sep 2014 13:16:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754764AbaILNQL (ORCPT ); Fri, 12 Sep 2014 09:16:11 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:34358 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754671AbaILNQI (ORCPT ); Fri, 12 Sep 2014 09:16:08 -0400 Received: by mail-we0-f173.google.com with SMTP id u56so729294wes.4 for ; Fri, 12 Sep 2014 06:16:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Wf11L3uW8JP5t1mWmM2v5ufJ4yKBGYglSRmD6JwvsQg=; b=fModJff1odi/trelU7jkDYlnjn6otgmDqkETGpm8u0Ewcz4FGS0OKcuffM+qWAQ1dn J4EVeqvjUlmRwxtELrLSlbcq9un9ZH7OmUQ+G5RvWZcKgZRWKTmTHQ/knsDySSw2OGry sgIi4nJ3rYKjSQ2NzNNQQEwR4fFZUGT71QSVR7IUFZ/V2Vhj0/xKGWwCcGDkxgWJ+FjS uSQUa17D3y5pOeX+CEdz3yClH+3uJDlooj6jtKb4XHwO0036LAVLuzcGj4gq6B9OMXlk rx/IukjC/SMwHgPNCgGKxgg7pUBnIsQRlspqVV6Y4BVZTFZc/KxJ7oppaxkC/7msxLnG R68A== X-Gm-Message-State: ALoCoQmUc980UH/SHRjd7mLadoEG7xZk9x+0ZHKW9TRocNmNnIamyJwHViGknOEojX9gx6mAR3Ek X-Received: by 10.180.91.111 with SMTP id cd15mr2165822wib.69.1410527763347; Fri, 12 Sep 2014 06:16:03 -0700 (PDT) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id pm6sm4517345wjb.36.2014.09.12.06.16.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Sep 2014 06:16:02 -0700 (PDT) From: Ard Biesheuvel To: gleb@kernel.org, pbonzini@redhat.com, marc.zyngier@arm.com, christoffer.dall@linaro.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, steve.capper@linaro.org Cc: lersek@redhat.com, fu.wei@linaro.org, peter.maydell@linaro.org, Ard Biesheuvel Subject: [PATCH] KVM: check for !is_zero_pfn() in kvm_is_mmio_pfn() Date: Fri, 12 Sep 2014 15:16:00 +0200 Message-Id: <1410527760-19737-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Read-only memory ranges may be backed by the zero page, so avoid misidentifying it a a MMIO pfn. Signed-off-by: Ard Biesheuvel Fixes: b88657674d39 ("ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping") --- This fixes another issue I identified when testing QEMU+KVM_UEFI, where a read to an uninitialized emulated NOR flash brought in the zero page, but mapped as a read-write device region, because kvm_is_mmio_pfn() misidentifies it as a MMIO pfn due to its PG_reserved bit being set. virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 36b887dd0c84..f8adaabeac13 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -110,7 +110,7 @@ static bool largepages_enabled = true; bool kvm_is_mmio_pfn(pfn_t pfn) { if (pfn_valid(pfn)) - return PageReserved(pfn_to_page(pfn)); + return !is_zero_pfn(pfn) && PageReserved(pfn_to_page(pfn)); return true; }