From patchwork Fri Nov 30 20:22:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 1828121 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E2D1C3FE80 for ; Fri, 30 Nov 2012 20:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756926Ab2K3UWa (ORCPT ); Fri, 30 Nov 2012 15:22:30 -0500 Received: from mail-ia0-f174.google.com ([209.85.210.174]:40298 "EHLO mail-ia0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756646Ab2K3UW3 (ORCPT ); Fri, 30 Nov 2012 15:22:29 -0500 Received: by mail-ia0-f174.google.com with SMTP id y25so672363iay.19 for ; Fri, 30 Nov 2012 12:22:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=wu4toURorM9n4twBBT9h3LIyXB0y04SFcZdvQBzGuBc=; b=QFzVcRzSNCRZtSZVPa1pIetbsZSmgKyQyjEHQtZrwPZQwI8MhANSNkPZi+YkDx2NlP ccnj8QOcJ0E7BRTR6TfsAG8WgcI49rVcsk37zQswuqHh8iXg4Ri9Sev1U28TOH9iB7jv luT/PJc0CbfyiDT/3Cz8hY6sn4jC2/kg/W9zdXg+Iw3POUiPiueIG6KdkF4oTJbx0Zzz ADapSPpxKeUw9CLUer8W5IqkDMAYx5vWK8/lHR6NE9Upm9dUeGDeDTE5ErQ22lVYyJAy mvHZ1+nH8MO/MdAHSqkNFKTrggu52nMTCJ4pqPUtf/2YIVdIieQMjzsgRBTSKpaKD7b5 VpoQ== MIME-Version: 1.0 Received: by 10.50.140.38 with SMTP id rd6mr2208659igb.35.1354306948920; Fri, 30 Nov 2012 12:22:28 -0800 (PST) Received: by 10.64.44.174 with HTTP; Fri, 30 Nov 2012 12:22:28 -0800 (PST) X-Originating-IP: [72.80.83.148] In-Reply-To: <20121119150105.GB3205@mudshark.cambridge.arm.com> References: <20121110154203.2836.46686.stgit@chazy-air> <20121110154313.2836.2851.stgit@chazy-air> <20121119150105.GB3205@mudshark.cambridge.arm.com> Date: Fri, 30 Nov 2012 15:22:28 -0500 Message-ID: Subject: Re: [PATCH v4 09/14] KVM: ARM: Emulation framework and CP15 emulation From: Christoffer Dall To: Will Deacon Cc: "kvm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , Marcelo Tosatti , Rusty Russell X-Gm-Message-State: ALoCoQllLpmQyx7Eea97mzfN4fWIf1dMSy+G8me9hROirT57q6r7ceWZKm51iu1o/sNe3hwVBsQx Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Nov 19, 2012 at 10:01 AM, Will Deacon wrote: > On Sat, Nov 10, 2012 at 03:43:13PM +0000, Christoffer Dall wrote: >> Adds a new important function in the main KVM/ARM code called >> handle_exit() which is called from kvm_arch_vcpu_ioctl_run() on returns >> from guest execution. This function examines the Hyp-Syndrome-Register >> (HSR), which contains information telling KVM what caused the exit from >> the guest. >> >> Some of the reasons for an exit are CP15 accesses, which are >> not allowed from the guest and this commit handles these exits by >> emulating the intended operation in software and skipping the guest >> instruction. >> >> Minor notes about the coproc register reset: >> 1) We reserve a value of 0 as an invalid cp15 offset, to catch bugs in our >> table, at cost of 4 bytes per vcpu. >> >> 2) Added comments on the table indicating how we handle each register, for >> simplicity of understanding. >> >> Reviewed-by: Marcelo Tosatti >> Signed-off-by: Rusty Russell >> Signed-off-by: Christoffer Dall > > [...] > >> diff --git a/arch/arm/kvm/coproc_a15.c b/arch/arm/kvm/coproc_a15.c >> new file mode 100644 >> index 0000000..55cb4a3 >> --- /dev/null >> +++ b/arch/arm/kvm/coproc_a15.c >> @@ -0,0 +1,164 @@ >> +/* >> + * Copyright (C) 2012 - Virtual Open Systems and Columbia University >> + * Authors: Rusty Russell >> + * Christoffer Dall >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License, version 2, as >> + * published by the Free Software Foundation. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + * GNU General Public License for more details. >> + * >> + * You should have received a copy of the GNU General Public License >> + * along with this program; if not, write to the Free Software >> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. >> + */ >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#define MPIDR_CPUID 0x3 > > This should probably be 0xff and also use the macros that Lorenzo is > introducing: > > http://lists.infradead.org/pipermail/linux-arm-kernel/2012-November/132977.html > in the A15 TRM bits [7:2] are reserved, so we really only do care about bits [1:0], and this file is A15 specific, but if you prefer, I can merge this: #include "coproc.h" --- -Christoffer -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/kvm/coproc_a15.c b/arch/arm/kvm/coproc_a15.c index 55cb4a3..685063a 100644 --- a/arch/arm/kvm/coproc_a15.c +++ b/arch/arm/kvm/coproc_a15.c @@ -24,8 +24,6 @@ #include #include -#define MPIDR_CPUID 0x3 - static void reset_mpidr(struct kvm_vcpu *vcpu, const struct coproc_reg *r) { /* @@ -35,8 +33,8 @@ static void reset_mpidr(struct kvm_vcpu *vcpu, const struct coproc_reg *r) * revealing the underlying hardware properties is likely to * be the best choice). */ - vcpu->arch.cp15[c0_MPIDR] = (read_cpuid_mpidr() & ~MPIDR_CPUID) - | (vcpu->vcpu_id & MPIDR_CPUID); + vcpu->arch.cp15[c0_MPIDR] = (read_cpuid_mpidr() & ~MPIDR_LEVEL_MASK) + | (vcpu->vcpu_id & MPIDR_LEVEL_MASK); }