From patchwork Mon Nov 10 08:33:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 5264751 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 52CBD9F2ED for ; Mon, 10 Nov 2014 08:34:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7871920166 for ; Mon, 10 Nov 2014 08:34:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 941C020127 for ; Mon, 10 Nov 2014 08:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbaKJId5 (ORCPT ); Mon, 10 Nov 2014 03:33:57 -0500 Received: from mail-wi0-f182.google.com ([209.85.212.182]:37773 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268AbaKJIdz (ORCPT ); Mon, 10 Nov 2014 03:33:55 -0500 Received: by mail-wi0-f182.google.com with SMTP id d1so9568152wiv.15 for ; Mon, 10 Nov 2014 00:33:53 -0800 (PST) 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=8AD+/2qT5cyyK7yhBSNlYCLTD0fOYxS9wd5JC5KB7yc=; b=QlWWVkyHAMGajwKX5TTebCyqUEAx/85cO2FvdqJogNgU8bSRWoRqCNlEtHNOtiANLJ LQOxzsxfcSRVDGxDVUcJy5yQrSc8n0sMRH5zo5ECSLGfjdhJARYcUeBaOFbtmrwfNfr2 /uiKe6/ceqo+LURTeXU6CgFr9INQkrqFHkcvrr6+pMth6UqyvjjcJyzLYyEjjrlW2UQe Tl9XKdTbWDIh5qYovHZoGRpGuI4HvGwFKaqasMqDFp0HYrouH46ReLlrJrjiLvFcGtNr wvGoH9U50zh0R3tcmn0eOYqd9ZfFPtQwTML73wrO422dbnRxcupHVbpPDL2/cxyyQd7n A1LA== X-Gm-Message-State: ALoCoQnnuCm4vn8unJoYbGF1kepOh70zMBq1Q476mGZ/dGqf5WOBNItu1wVYEdPU4ohUSW5MdH4W X-Received: by 10.194.71.84 with SMTP id s20mr10243426wju.128.1415608433731; Mon, 10 Nov 2014 00:33:53 -0800 (PST) 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 dr5sm12495384wib.4.2014.11.10.00.33.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Nov 2014 00:33:52 -0800 (PST) From: Ard Biesheuvel To: magnus.karlsson@avagotech.com, christoffer.dall@linaro.org, pbonzini@redhat.com, m.smarduch@samsung.com Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, marc.zyngier@arm.com, Ard Biesheuvel Subject: [PATCH 1/2] arm/arm64: kvm: drop inappropriate use of kvm_is_mmio_pfn() Date: Mon, 10 Nov 2014 09:33:55 +0100 Message-Id: <1415608436-5127-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=-7.5 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 Instead of using kvm_is_mmio_pfn() to decide whether a host region should be stage 2 mapped with device attributes, add a new static function kvm_is_device_pfn() that disregards RAM pages with the reserved bit set, as those should usually not be mapped as device memory. Signed-off-by: Ard Biesheuvel Acked-by: Christoffer Dall Acked-by: Christoffer Dall --- arch/arm/kvm/mmu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 57a403a5c22b..b007438242e2 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -834,6 +834,11 @@ static bool kvm_is_write_fault(struct kvm_vcpu *vcpu) return kvm_vcpu_dabt_iswrite(vcpu); } +static bool kvm_is_device_pfn(unsigned long pfn) +{ + return !pfn_valid(pfn); +} + static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, struct kvm_memory_slot *memslot, unsigned long hva, unsigned long fault_status) @@ -904,7 +909,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (is_error_pfn(pfn)) return -EFAULT; - if (kvm_is_mmio_pfn(pfn)) + if (kvm_is_device_pfn(pfn)) mem_type = PAGE_S2_DEVICE; spin_lock(&kvm->mmu_lock);