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: 1828131 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 8821ADF24C for ; Fri, 30 Nov 2012 20:25:29 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TeX6Z-0002tw-Kd; Fri, 30 Nov 2012 20:22:35 +0000 Received: from mail-ie0-f177.google.com ([209.85.223.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TeX6U-0002tb-D0 for linux-arm-kernel@lists.infradead.org; Fri, 30 Nov 2012 20:22:32 +0000 Received: by mail-ie0-f177.google.com with SMTP id k13so1230123iea.36 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=JT6JFL2P31rhu/pQgLXThApw6x881zLhHYdzFLeN5q062xz3AXcukpp3+07ZEPnWZv 6Tl6iIodF0geN1LDFSucvbdZ+EHhkOrRKtIaybr9MfEiAoaSpJXRlaVRTOXAwUVHWb2+ W96nfcAGOcQfRpcBEcNXAOKq7dcvgzTCFcqcf/hXF3k/R8Q4N2mMMinMtlSgFIxpolac s9fJFXWCF3/NbTpZnaiVgTrIFx+e8VdLgfO+Z5haVTYp+ihvxwaZsxBPh6adzAZU5qxK T+jj0T1C/ZXjfiM4Glu/Hp+B/aZI0YnJxtixdRKwz2YHHCHk3n62t9loCyJGR4B4JHCm z8vw== 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 X-Gm-Message-State: ALoCoQldZ2gMJAvq7OrABCTpH3LNm0obZ9z4aZvNSAm5yWIT8qeyLStl49Qnvzq1AMBvocs5OyXr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121130_152230_543946_4BBBC079 X-CRM114-Status: GOOD ( 22.32 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.223.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Rusty Russell , Marcelo Tosatti , "linux-arm-kernel@lists.infradead.org" , "kvm@vger.kernel.org" , "kvmarm@lists.cs.columbia.edu" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 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); }