|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 1/2] arm: smccc: handle SMCs/HVCs according to SMCCC
Hello Julien,Thank you for review. It is my first time, when I'm submitting patch to XEN, so I have some questions. On 15.06.17 13:48, Julien Grall wrote: Should we return ARM_SMCCC_ERR_UNKNOWN_FUNCTION code in this case? Or inject undefined instruction?On 14/06/17 15:10, Volodymyr Babchuk wrote:SMCCC (SMC Call Convention) describes how to handle both HVCs and SMCs.SMCCC states that both HVC and SMC are valid conduits to call to a differentfirmware functions. Thus, for example PSCI calls can be made both by SMC or HVC. Also SMCCC defines function number coding for such calls. Besides functional calls there are query calls, which allows underling OS determine version, UID and number of functions provided by service provider. This patch adds new file `smccc.c`, which handles both generic SMCs and HVC according to SMC. At this moment it implements only one service: Standard Hypervisor Service. Standard Hypervisor Service only supports query calls, so caller can ask about hypervisor UID and determine that it is XEN running. This change allows more generic handling for SMCs and HVCs and it can be easily extended to support new services and functions. Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx> Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx> --- xen/arch/arm/Makefile | 1 +xen/arch/arm/smccc.c | 96 +++++++++++++++++++++++++++++++++++++++++++++xen/arch/arm/traps.c | 10 ++++-xen/include/asm-arm/smccc.h | 89 +++++++++++++++++++++++++++++++++++++++++4 files changed, 194 insertions(+), 2 deletions(-) create mode 100644 xen/arch/arm/smccc.c create mode 100644 xen/include/asm-arm/smccc.h diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 49e1fb2..b8728cf 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -39,6 +39,7 @@ obj-y += psci.o obj-y += setup.o obj-y += shutdown.o obj-y += smc.o +obj-y += smccc.o obj-y += smp.o obj-y += smpboot.o obj-y += sysctl.o diff --git a/xen/arch/arm/smccc.c b/xen/arch/arm/smccc.c new file mode 100644 index 0000000..5d10964 --- /dev/null +++ b/xen/arch/arm/smccc.cI would name this file vsmccc.c to show it is about virtual SMC. Also, I would have expected pretty everyone to use the SMCC, so I would even name the file vsmc.c@@ -0,0 +1,96 @@ +/* + * xen/arch/arm/smccc.c + * + * Generic handler for SMC and HVC calls according to + * ARM SMC callling conventions/callling/calling/+ * + * 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.I know that some of the other headers are wrong about the GPL license. But Xen is GPLv2 only. Please update the copyright accordingly. I.e:* 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. + */ + + +#include <xen/config.h> +#include <xen/lib.h> +#include <xen/perfc.h>Why this is included here? You don't use it.+/* Need to include xen/sched.h before asm/domain.h or it breaks build*/xen/sched.h will include asm/domain.h. So no need to include the latter here.+#include <xen/sched.h> +#include <xen/stdbool.h> +#include <xen/types.h> +#include <asm/domain.h> +#include <asm/psci.h>You don't use this header here.+#include <asm/smccc.h> +#include <asm/regs.h> + +#define XEN_SMCCC_UID ARM_SMCCC_UID(0xa71812dc, 0xc698, 0x4369, \ + 0x9a, 0xcf, 0x79, 0xd1, \ + 0x8d, 0xde, 0xe6, 0x67)Please mention that this value was generated. This would avoid to wonder where this value comes from.+ +/* + * We can't use XEN version here: + * Major revision should change every time SMC/HVC function is removed. + * Minor revision should change every time SMC/HVC function is added. + * So, it is SMCCC protocol revision code, not XEN versionIt would be nice to say this is a requirement of the spec. Also missing full stop.+ */ +#define XEN_SMCCC_MAJOR_REVISION 0 +#define XEN_SMCCC_MINOR_REVISION 1I first thought the revision was 0.1.3 and was about to ask why. But then noticed XEN_SMCC_FUNCTION_COUNT is not part of the revision.So please add a newline for clarity.+#define XEN_SMCCC_FUNCTION_COUNT 3 + +/* SMCCC interface for hypervisor. Tell about self */Tell about itself. + missing full stop.+static bool handle_hypervisor(struct cpu_user_regs *regs, const union hsr hsr)hsr is already part of regs. Furthermore, based from the SMCCC spec (see 2.9 in ARM DEN 0028B), the compliant SMC calls should have the immediate value of zero.Looks like HSR does not hold immediate value (as if in case of HVC/SVC). That means that I need to map memory at PC and decode instruction manually. It is a bit complex, I think. Should we do this?
by myself. What I should to in this case? +#define ARM_SMCCC_FAST_CALL 1 +#define ARM_SMCCC_TYPE_SHIFT 31 + +#define ARM_SMCCC_SMC_32 0 +#define ARM_SMCCC_SMC_64 1 +#define ARM_SMCCC_CALL_CONV_SHIFT 30 + +#define ARM_SMCCC_OWNER_MASK 0x3F +#define ARM_SMCCC_OWNER_SHIFT 24 + +#define ARM_SMCCC_FUNC_MASK 0xFFFF + +#define ARM_SMCCC_IS_FAST_CALL(smc_val) \ + ((smc_val) & (ARM_SMCCC_FAST_CALL << ARM_SMCCC_TYPE_SHIFT)) +#define ARM_SMCCC_IS_64(smc_val) \ + ((smc_val) & (ARM_SMCCC_SMC_64 << ARM_SMCCC_CALL_CONV_SHIFT)) +#define ARM_SMCCC_FUNC_NUM(smc_val) ((smc_val) & ARM_SMCCC_FUNC_MASK) +#define ARM_SMCCC_OWNER_NUM(smc_val) \ + (((smc_val) >> ARM_SMCCC_OWNER_SHIFT) & ARM_SMCCC_OWNER_MASK) + +#define ARM_SMCCC_CALL_VAL(type, calling_convention, owner, func_num) \ + (((type) << ARM_SMCCC_TYPE_SHIFT) | \ + ((calling_convention) << ARM_SMCCC_CALL_CONV_SHIFT) | \ + (((owner) & ARM_SMCCC_OWNER_MASK) << ARM_SMCCC_OWNER_SHIFT) | \ + ((func_num) & ARM_SMCCC_FUNC_MASK))I would appreciate a bit more documentation of those macros as they are a bit difficult to parse. Also some newline would be nice for clarity. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |