From patchwork Tue Feb 11 20:04:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 24502 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5CB3D203F3 for ; Tue, 11 Feb 2014 20:07:18 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id i4sf35405837oah.3 for ; Tue, 11 Feb 2014 12:07:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=o2IxV12+DpeXOcMqG3WpcrtfsLeeZGx63t2Icdu4Zhs=; b=HlFAwNdtp0l5R0YUx2NnFWY3TgigX+7T63C5lts9vBPYR6Ikd6RfI6NuUS4G0qRPjk aQ2DhQMJKxoLZf11xcl9Ns3eChUW5OzRO8ZKuQ/1KsbaeaqDp5B5fA74Ibds6bFvmApw plx5yg/OSBnXy+ZuPFYybH45jPPz7YtfWKguLUhS20dqdouc6J7F2yzKKZxlqKcp3D/0 yvUbYzcDDifAuzk0jUnNjYGUX5K2VXmPpJ6JzWTRbc2nel9rzygOavHbkzyMgnh8FfTz sAFNve3irD8Am+6XPObV4m89NhmtsjdzLYlPLmWS3Ykt/IkBgJeZMg09RcP3wl/+MIQ1 D4Qw== X-Gm-Message-State: ALoCoQkMZ2Fg23S7PI+aqwcxIQNeCwWK0yiscCoA1q/cwt/KmOj7lWYeSZ4TTlI8SwmXImvgGrOC X-Received: by 10.182.104.200 with SMTP id gg8mr141471obb.45.1392149237122; Tue, 11 Feb 2014 12:07:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.165 with SMTP id x34ls1612472qgx.53.gmail; Tue, 11 Feb 2014 12:07:17 -0800 (PST) X-Received: by 10.58.133.15 with SMTP id oy15mr28661530veb.19.1392149237017; Tue, 11 Feb 2014 12:07:17 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id kl10si6332598vdb.12.2014.02.11.12.07.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 12:07:17 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id oy12so6712375veb.9 for ; Tue, 11 Feb 2014 12:07:16 -0800 (PST) X-Received: by 10.58.24.196 with SMTP id w4mr1983vef.48.1392149236907; Tue, 11 Feb 2014 12:07:16 -0800 (PST) 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.220.174.196 with SMTP id u4csp273317vcz; Tue, 11 Feb 2014 12:07:15 -0800 (PST) X-Received: by 10.224.114.78 with SMTP id d14mr61417064qaq.19.1392149234532; Tue, 11 Feb 2014 12:07:14 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id f91si13303353qge.198.2014.02.11.12.07.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Feb 2014 12:07:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WDJZp-00054X-5Z; Tue, 11 Feb 2014 20:05:05 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WDJZn-00053n-UR for xen-devel@lists.xenproject.org; Tue, 11 Feb 2014 20:05:04 +0000 Received: from [85.158.139.211:9942] by server-2.bemta-5.messagelabs.com id 4D/62-23037-F628AF25; Tue, 11 Feb 2014 20:05:03 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-206.messagelabs.com!1392149101!3263212!1 X-Originating-IP: [74.125.83.41] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.9.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26799 invoked from network); 11 Feb 2014 20:05:01 -0000 Received: from mail-ee0-f41.google.com (HELO mail-ee0-f41.google.com) (74.125.83.41) by server-12.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 11 Feb 2014 20:05:01 -0000 Received: by mail-ee0-f41.google.com with SMTP id e51so3304424eek.0 for ; Tue, 11 Feb 2014 12:05:01 -0800 (PST) X-Received: by 10.14.220.193 with SMTP id o41mr46873552eep.22.1392149101485; Tue, 11 Feb 2014 12:05:01 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id v6sm51090920eef.2.2014.02.11.12.05.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2014 12:05:00 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 11 Feb 2014 20:04:44 +0000 Message-Id: <1392149085-14366-5-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1392149085-14366-1-git-send-email-julien.grall@linaro.org> References: <1392149085-14366-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [RFC for-4.5 4/5] xen/arm: Remove processor specific setup in vcpu_initialise X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 List-Archive: This patch introduces the possibility to have specific processor callbacks that can be called in various place. Currently VCPU initialization code contains processor specific setup (for Cortex A7 and Cortex A15) for the ACTRL registers. It's possible to have processor with a different layout for this register. Move this setup in a specific callback for ARM v7 processor. Signed-off-by: Julien Grall --- xen/arch/arm/Makefile | 1 + xen/arch/arm/arm32/Makefile | 2 +- xen/arch/arm/arm32/proc-v7-c.c | 32 ++++++++++++++++++++++++++ xen/arch/arm/arm32/proc-v7.S | 3 +++ xen/arch/arm/domain.c | 8 ++----- xen/arch/arm/processor.c | 49 ++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/setup.c | 3 +++ xen/include/asm-arm/procinfo.h | 17 ++++++++++++-- 8 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 xen/arch/arm/arm32/proc-v7-c.c create mode 100644 xen/arch/arm/processor.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index d70f6d5..63e0460 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -32,6 +32,7 @@ obj-y += vuart.o obj-y += hvm.o obj-y += device.o obj-y += decode.o +obj-y += processor.o #obj-bin-y += ....o diff --git a/xen/arch/arm/arm32/Makefile b/xen/arch/arm/arm32/Makefile index 65ecff4..0e7c3b4 100644 --- a/xen/arch/arm/arm32/Makefile +++ b/xen/arch/arm/arm32/Makefile @@ -1,7 +1,7 @@ subdir-y += lib obj-y += entry.o -obj-y += proc-v7.o +obj-y += proc-v7.o proc-v7-c.o obj-y += traps.o obj-y += domain.o diff --git a/xen/arch/arm/arm32/proc-v7-c.c b/xen/arch/arm/arm32/proc-v7-c.c new file mode 100644 index 0000000..a3b94a2 --- /dev/null +++ b/xen/arch/arm/arm32/proc-v7-c.c @@ -0,0 +1,32 @@ +/* + * xen/arch/arm/arm32/proc-v7-c.c + * + * arm v7 specific initializations (C part) + * + * Julien Grall + * Copyright (c) 2014 Linaro Limited. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ +#include +#include + +static void armv7_vcpu_initialize(struct vcpu *v) +{ + if ( v->domain->max_vcpus > 1 ) + v->arch.actlr |= ACTLR_V7_SMP; + else + v->arch.actlr &= ~ACTLR_V7_SMP; +} + +const struct processor armv7_processor = { + .vcpu_initialize = armv7_vcpu_initialize, +}; diff --git a/xen/arch/arm/arm32/proc-v7.S b/xen/arch/arm/arm32/proc-v7.S index 2c8cb9c..d7d2318 100644 --- a/xen/arch/arm/arm32/proc-v7.S +++ b/xen/arch/arm/arm32/proc-v7.S @@ -33,6 +33,7 @@ __v7_ca15mp_proc_info: .long 0x410FC0F0 /* Cortex-A15 */ .long 0xFF0FFFF0 /* Mask */ .long v7_init + .long armv7_processor .size __v7_ca15mp_proc_info, . - __v7_ca15mp_proc_info .section ".init.proc.info", #alloc, #execinstr @@ -41,6 +42,7 @@ __v7_ca7mp_proc_info: .long 0x410FC070 /* Cortex-A7 */ .long 0xFF0FFFF0 /* Mask */ .long v7_init + .long armv7_processor .size __v7_ca7mp_proc_info, . - __v7_ca7mp_proc_info .section ".init.proc.info", #alloc, #execinstr @@ -49,6 +51,7 @@ __v7_brahma15mp_proc_info: .long 0x420F00F2 /* Broadcom Brahma-B15 */ .long 0xFF0FFFFF /* Mask */ .long v7_init + .long armv7_processor .size __v7_brahma15mp_proc_info, . - __v7_brahma15mp_proc_info /* diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index c279a27..df23147 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -487,11 +487,7 @@ int vcpu_initialise(struct vcpu *v) v->arch.actlr = READ_SYSREG32(ACTLR_EL1); - /* XXX: Handle other than CA15 cpus */ - if ( v->domain->max_vcpus > 1 ) - v->arch.actlr |= ACTLR_CA15_SMP; - else - v->arch.actlr &= ~ACTLR_CA15_SMP; + processor_vcpu_initialize(v); if ( (rc = vcpu_vgic_init(v)) != 0 ) return rc; diff --git a/xen/arch/arm/processor.c b/xen/arch/arm/processor.c new file mode 100644 index 0000000..b06fcc5 --- /dev/null +++ b/xen/arch/arm/processor.c @@ -0,0 +1,49 @@ +/* + * xen/arch/arm/processor.c + * + * Helpers to execute processor specific code. + * + * Julien Grall + * Copyright (C) 2014 Linaro Limited. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ +#include + +static const struct processor *processor = NULL; + +void __init processor_setup(void) +{ + const struct proc_info_list *procinfo; + + procinfo = lookup_processor_type(); + if ( !procinfo ) + return; + + processor = procinfo->processor; +} + +void processor_vcpu_initialize(struct vcpu *v) +{ + if ( !processor || !processor->vcpu_initialize ) + return; + + processor->vcpu_initialize(v); +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 1f6d713..5529cb1 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -42,6 +42,7 @@ #include #include #include +#include struct cpuinfo_arm __read_mostly boot_cpu_data; @@ -148,6 +149,8 @@ static void __init processor_id(void) { printk("32-bit Execution: Unsupported\n"); } + + processor_setup(); } static void dt_unreserved_regions(paddr_t s, paddr_t e, diff --git a/xen/include/asm-arm/procinfo.h b/xen/include/asm-arm/procinfo.h index 9d3feb7..9cb7a86 100644 --- a/xen/include/asm-arm/procinfo.h +++ b/xen/include/asm-arm/procinfo.h @@ -21,10 +21,23 @@ #ifndef __ASM_ARM_PROCINFO_H #define __ASM_ARM_PROCINFO_H +#include + +struct processor { + /* Initialize specific processor register for the new VPCU*/ + void (*vcpu_initialize)(struct vcpu *v); +}; + struct proc_info_list { - unsigned int cpu_val; - unsigned int cpu_mask; + unsigned int cpu_val; + unsigned int cpu_mask; void (*cpu_init)(void); + struct processor *processor; }; +const __init struct proc_info_list *lookup_processor_type(void); + +void __init processor_setup(void); +void processor_vcpu_initialize(struct vcpu *v); + #endif