AALLeeXXX
Posts: 57
Joined: Sun Apr 10, 2016 1:37 pm
Location: Yokohama

gcc options for virtualisation ?

Wed Aug 30, 2017 1:56 pm

Hello everybody,

I'm trying to embed a HVC instruction in my C source directly, with a statement asm ("hvc"); but gcc reports the following error:

Code: Select all

arm-none-eabi-gcc -c -O0 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7-a -mtune=cortex-a7 -g -nostartfiles -Wa,-acdghln=obj/pishell.lst -DRPI2 -o obj/pishell.o src/pishell.c
/tmp/ccY0ON4h.s: Assembler messages:
/tmp/ccY0ON4h.s:1359: Error: selected processor does not support ARM mode `hvc'
make: *** [obj/pishell.o] Error 1
make: Target 'image' not remade because of errors.
Options I selected should match my PI2 I think, but seems virtualisation is not considered. In gcc documentation I could not find any dedicated option for virtualisation or hypervisor. I'm sure I missed something but still could not find it.

In assembler I perfectly can use this instruction, with following options:

Code: Select all

AOPS = --warn --fatal-warnings 
obj/start_$(SRC).o: src/$(ASMLIST)
	echo Building assembler file
	echo TCPREFIX = $(TCPREFIX)
	$(TCPREFIX)-as $(AOPS) $^ -o $@ -acdghln=$(basename $@).lst
Nothing processor specific.
I alreeady noticed previously ERET was not supported if I enabled for the assembler processor specific options, like above for gcc:

Code: Select all

AOPS = --warn --fatal-warnings -march=armv7-a 
Seems virtualisation features require a special options set ?

Thanks in advance for any hints.

ALeX

LdB
Posts: 520
Joined: Wed Dec 07, 2016 2:29 pm

Re: gcc options for virtualisation ?

Wed Aug 30, 2017 2:53 pm

I have only done it on ARM8 and it's supported there.

I have however seen a weird macro in lots of places
https://github.com/u-boot/u-boot/blob/m ... des-virt.h

#define __HVC(imm16) __inst_arm_thumb32( \
0xE1400070 | (((imm16) & 0xFFF0) << 4) | ((imm16) & 0x000F), \
0xF7E08000 | (((imm16) & 0xF000) << 4) | ((imm16) & 0x0FFF) \
)

I think you may have just answered why :-)

User avatar
Paeryn
Posts: 1573
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: gcc options for virtualisation ?

Wed Aug 30, 2017 2:56 pm

They are available, you haven't told gcc the correct architecture, it's -march=armv7ve (armv7-a with virtualisation extensions). I don't think it's an official architecture name but since an implementation of armv7-a doesn't have to support the virtualisation extensions gcc uses it to stop you compiling code for processors that don't support it.

You could have, instead of using -march and -mtune, just used -mcpu=cortex-a7 that will set the architecture to the correct value for the cpu as well as setting the tuning.
She who travels light — forgot something.

AALLeeXXX
Posts: 57
Joined: Sun Apr 10, 2016 1:37 pm
Location: Yokohama

Re: gcc options for virtualisation ?

Fri Sep 01, 2017 2:07 pm

Hello Thanks for the reply.
Well, indeed in the tools chain I was using, a pretty old one (gcc-arm-none-eabi-4_7-2013q3) the armv7ve was not available.
Then I changed to a recent toolchain gcc-arm-none-eabi-6-2017-q2-update... but I don't get any better result with either one or other options set:

Code: Select all

arm-none-eabi-gcc -c -O0 -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 -g -nostartfiles -Wa,-acdghln=obj/pishell.lst -DRPI2 -o obj/pishell.o src/pishell.c
/tmp/ccszoern.s: Assembler messages:
/tmp/ccszoern.s:1397: Error: missing expression -- `hvc'
Makefile:52: recipe for target 'obj/pishell.o' failed
make: *** [obj/pishell.o] Error 1
Or

Code: Select all

arm-none-eabi-gcc -c -O0 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve -mtune=cortex-a7 -g -nostartfiles -Wa,-acdghln=obj/pishell.lst -DRPI2 -o obj/pishell.o src/pishell.c
/tmp/cccHL8L9.s: Assembler messages:
/tmp/cccHL8L9.s:1401: Error: missing expression -- `hvc'
Makefile:52: recipe for target 'obj/pishell.o' failed
make: *** [obj/pishell.o] Error 1
Am I still missing something here ?

AALLeeXXX
Posts: 57
Joined: Sun Apr 10, 2016 1:37 pm
Location: Yokohama

Re: gcc options for virtualisation ?

Fri Sep 01, 2017 2:17 pm

Code: Select all

#define __HVC(imm16) __inst_arm_thumb32( \
0xE1400070 | (((imm16) & 0xFFF0) << 4) | ((imm16) & 0x000F), \
0xF7E08000 | (((imm16) & 0xF000) << 4) | ((imm16) & 0x0FFF) \
)
Wooo, indeed !!
Seems however this code is pretty ld now, 2012... maybe gcc did not support virtualisation instructions ?
But they made it anyway ;-)

LdB
Posts: 520
Joined: Wed Dec 07, 2016 2:29 pm

Re: gcc options for virtualisation ?

Fri Sep 01, 2017 2:40 pm

I am on 6.3 Official ARM GCC with settings
-mfpu=neon -mfloat-abi=hard -march=armv7ve -mtune=cortex-a7

and this works just fine
hvc #0

I get your error if I forget to put some immediate value after it like
hvc

results in
SmartStart32.S:85: Error: missing expression -- `hvc'

AALLeeXXX
Posts: 57
Joined: Sun Apr 10, 2016 1:37 pm
Location: Yokohama

Re: gcc options for virtualisation ?

Fri Sep 01, 2017 3:24 pm

Oh, ok, confirmed !
arm-none-eabi-gcc -c -O0 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve -mtune=cortex-a7 -g -nostartfiles -Wa,-acdghln=obj/pishell.lst -DRPI2 -o obj/pishell.o src/pishell.c

Works fine with the immediate value as argument, I though it was optional.

Thanks !!

Return to “Bare metal”

Who is online

Users browsing this forum: No registered users and 8 guests