[kvm-unit-tests,v4,04/13] s390x: Switch to z/Arch
diff mbox series

Message ID 20190103100806.9039-5-frankja@linux.ibm.com
State New
Headers show
Series
  • 390x: Add cross hypervisor and disk boot
Related show

Commit Message

Janosch Frank Jan. 3, 2019, 10:07 a.m. UTC
LPAR and z/VM start in esam mode depending on the hardware, so we need
to switch to z/Arch and set 64 bit addressing.

Under Qemu/KVM we already start out with both when being run with the
Qemu --kernel argument or we lack 64 bit when booting from disk
because of the initial psw specifying 31 bit for z/VM and lpar
compatibility.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
 s390x/cstart64.S | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Thomas Huth Jan. 3, 2019, 12:37 p.m. UTC | #1
On 2019-01-03 11:07, Janosch Frank wrote:
> LPAR and z/VM start in esam mode depending on the hardware, so we need
> to switch to z/Arch and set 64 bit addressing.
> 
> Under Qemu/KVM we already start out with both when being run with the
> Qemu --kernel argument or we lack 64 bit when booting from disk
> because of the initial psw specifying 31 bit for z/VM and lpar
> compatibility.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
>  s390x/cstart64.S | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Reviewed-by: Thomas Huth <thuth@redhat.com>
Janosch Frank Jan. 3, 2019, 1:18 p.m. UTC | #2
On 03.01.19 13:37, Thomas Huth wrote:
> On 2019-01-03 11:07, Janosch Frank wrote:
>> LPAR and z/VM start in esam mode depending on the hardware, so we need
>> to switch to z/Arch and set 64 bit addressing.
>>
>> Under Qemu/KVM we already start out with both when being run with the
>> Qemu --kernel argument or we lack 64 bit when booting from disk
>> because of the initial psw specifying 31 bit for z/VM and lpar
>> compatibility.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> Reviewed-by: David Hildenbrand <david@redhat.com>
>> ---
>>  s390x/cstart64.S | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 

Thanks!
The title will be changed to:
s390x: Switch to z/Arch and enable 64 bit addressing mode

Also I will move the sam64 from the previous patch into this one.
Jens Remus Jan. 4, 2019, 8:56 a.m. UTC | #3
Hi Janosch,

happy new year!

On 03.01.2019 11:07, Janosch Frank wrote:
> LPAR and z/VM start in esam mode depending on the hardware, so we need

Did you consider the CZAM facility? You already use a so called "short 
PSW" (which is compatible to the ESA/390 PSW, as you did not set bit 31).

LPAR and z/VM start in esam or esame mode, depending on the hardware 
CZAM facility and z/VM MACHINE setting.

See POP section "Load State":

"When neither the configuration-z/Architecture-architectural-mode (CZAM) 
facility nor the ESA/390-compatibility-mode facility are installed, this 
sets the architectural mode to the ESA/390 mode. When the 
ESA/390-compatibility-mode facility is installed, this sets the 
architecture mode to the ESA/390-compatibility mode. When the CZAM 
facility is installed, the architectural mode is unchanged (that is, it 
remains in the z/Architecture architectural mode)."

> to switch to z/Arch and set 64 bit addressing.

Wouldn't it be nice to mention this in the commit subject:

s390x: Switch to z/Arch and 64-bit addressing [mode]

> Under Qemu/KVM we already start out with both when being run with the
> Qemu --kernel argument or we lack 64 bit when booting from disk
> because of the initial psw specifying 31 bit for z/VM and lpar
> compatibility.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
> ---
>   s390x/cstart64.S | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/s390x/cstart64.S b/s390x/cstart64.S
> index d382497..6622633 100644
> --- a/s390x/cstart64.S
> +++ b/s390x/cstart64.S
> @@ -11,6 +11,7 @@
>    * under the terms of the GNU Library General Public License version 2.
>    */
>   #include <asm/asm-offsets.h>
> +#include <asm/sigp.h>
>   
>   .section .init
>   
> @@ -20,9 +21,18 @@
>    *
>    * For KVM and TCG kernel boot we are in 64 bit z/Arch mode.
>    * When booting from disk the initial short psw is in 31 bit mode.
> + * When running under LPAR or z/VM, we might start in 31 bit and esam mode.
>    */
>   	.globl start
>   start:
> +	/* Switch to z/Architecture mode and 64-bit */
> +	slr     %r0, %r0		# Set cpuid to zero
> +	lhi     %r1, 2			# mode 2 = esame
> +	sigp    %r1, %r0, SIGP_SET_ARCHITECTURE
> +	/* XOR all registers with themselves to clear them fully. */
> +	.irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
> +	xgr \i,\i
> +	.endr
>   	sam64				# Set addressing mode to 64 bit
>   	/* setup stack */
>   	larl	%r15, stackptr
> 

Regards,
Jens
Janosch Frank Jan. 4, 2019, 10:15 a.m. UTC | #4
On 04.01.19 09:56, Jens Remus wrote:
> Hi Janosch,
> 
> happy new year!

Thanks, same to you.

> 
> On 03.01.2019 11:07, Janosch Frank wrote:
>> LPAR and z/VM start in esam mode depending on the hardware, so we need
> 
> Did you consider the CZAM facility? You already use a so called "short 
> PSW" (which is compatible to the ESA/390 PSW, as you did not set bit 31).
> 
> LPAR and z/VM start in esam or esame mode, depending on the hardware 
> CZAM facility and z/VM MACHINE setting.
> 
> See POP section "Load State":
> 
> "When neither the configuration-z/Architecture-architectural-mode (CZAM) 
> facility nor the ESA/390-compatibility-mode facility are installed, this 
> sets the architectural mode to the ESA/390 mode. When the 
> ESA/390-compatibility-mode facility is installed, this sets the 
> architecture mode to the ESA/390-compatibility mode. When the CZAM 
> facility is installed, the architectural mode is unchanged (that is, it 
> remains in the z/Architecture architectural mode)."
> 
>> to switch to z/Arch and set 64 bit addressing.

I don't really want to test in which state I am and blindly setting
z/Arch and 64 bit is a valid course of action according to the AR.

> 
> Wouldn't it be nice to mention this in the commit subject:
> 
> s390x: Switch to z/Arch and 64-bit addressing [mode]

As commented yesterday (Message-ID:
<9644d7ab-d815-720d-f1a1-eee1a6a0c253@linux.ibm.com>):
The title will be changed to:
s390x: Switch to z/Arch and enable 64 bit addressing mode

Also I will move the sam64 from the previous patch into this one.


I might add to the comment that we do this no matter what configuration
we start out in, because it doesn't produce an exception.
Jens Remus Jan. 4, 2019, 2:55 p.m. UTC | #5
Hello Janosch!

On 04.01.2019 11:15, Janosch Frank wrote:
> On 04.01.19 09:56, Jens Remus wrote:
>> Hi Janosch,
>>
>> happy new year!
> 
> Thanks, same to you.
> 
>>
>> On 03.01.2019 11:07, Janosch Frank wrote:
>>> LPAR and z/VM start in esam mode depending on the hardware, so we need
>>
>> Did you consider the CZAM facility? You already use a so called "short
>> PSW" (which is compatible to the ESA/390 PSW, as you did not set bit 31).
>>
>> LPAR and z/VM start in esam or esame mode, depending on the hardware
>> CZAM facility and z/VM MACHINE setting.
>>
>> See POP section "Load State":
>>
>> "When neither the configuration-z/Architecture-architectural-mode (CZAM)
>> facility nor the ESA/390-compatibility-mode facility are installed, this
>> sets the architectural mode to the ESA/390 mode. When the
>> ESA/390-compatibility-mode facility is installed, this sets the
>> architecture mode to the ESA/390-compatibility mode. When the CZAM
>> facility is installed, the architectural mode is unchanged (that is, it
>> remains in the z/Architecture architectural mode)."
>>
>>> to switch to z/Arch and set 64 bit addressing.
> 
> I don't really want to test in which state I am and blindly setting
> z/Arch and 64 bit is a valid course of action according to the AR.

I completely agree with you. I was rather thinking of enhancing the 
commit message to make clear that LPAR and z/VM start either in esam or 
esame mode, depending on the hardware CZAM facility and z/VM MACHINE 
setting. Re-reading your commit message I must admit that it kind of 
already contains this with "depending on the hardware" and one may then 
deduct from the commit subject that it must be z/Arch (esame) otherwise.

>> Wouldn't it be nice to mention this in the commit subject:
>>
>> s390x: Switch to z/Arch and 64-bit addressing [mode]
> 
> As commented yesterday (Message-ID:
> <9644d7ab-d815-720d-f1a1-eee1a6a0c253@linux.ibm.com>):
> The title will be changed to:
> s390x: Switch to z/Arch and enable 64 bit addressing mode
> 
> Also I will move the sam64 from the previous patch into this one.
> 
> 
> I might add to the comment that we do this no matter what configuration
> we start out in, because it doesn't produce an exception.

That would be nice. Thanks!

Regards,
Jens

Patch
diff mbox series

diff --git a/s390x/cstart64.S b/s390x/cstart64.S
index d382497..6622633 100644
--- a/s390x/cstart64.S
+++ b/s390x/cstart64.S
@@ -11,6 +11,7 @@ 
  * under the terms of the GNU Library General Public License version 2.
  */
 #include <asm/asm-offsets.h>
+#include <asm/sigp.h>
 
 .section .init
 
@@ -20,9 +21,18 @@ 
  *
  * For KVM and TCG kernel boot we are in 64 bit z/Arch mode.
  * When booting from disk the initial short psw is in 31 bit mode.
+ * When running under LPAR or z/VM, we might start in 31 bit and esam mode.
  */
 	.globl start
 start:
+	/* Switch to z/Architecture mode and 64-bit */
+	slr     %r0, %r0		# Set cpuid to zero
+	lhi     %r1, 2			# mode 2 = esame
+	sigp    %r1, %r0, SIGP_SET_ARCHITECTURE
+	/* XOR all registers with themselves to clear them fully. */
+	.irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+	xgr \i,\i
+	.endr
 	sam64				# Set addressing mode to 64 bit
 	/* setup stack */
 	larl	%r15, stackptr