s390x/skey: Test for ADDRESSING exceptions
PATCH 1/1 s390x/skey: Test for ADDRESSING exceptions
... used to be broken in TCG, so let's add a very simple test for SSKE and ISKE. In order to test RRBE as well, introduce a helper to call the machine instruction.
Signed-off-by David Hildenbrand <[email protected]>
--- lib/s390x/asm/mem.h | 12 ++++++++++++ s390x/skey.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
lib/s390x/asm/mem.h +12 -0
@@ -50,6 +50,18 @@ static inline unsigned char get_storage_key(void *addr)return skey; } +static inline unsigned char reset_reference_bit (void *addr) +{ +int cc; + + asmvolatile ( +"rrbe 0,%1\n" +"ipm %0\n" +"srl %0,28\n" + :"=d" (cc) :"a" (addr) :"cc" ); +return cc; +} +#define PFMF_FSC_4K 0#define PFMF_FSC_1M 1#define PFMF_FSC_2G 2
s390x/skey.c +28 -0
@@ -120,6 +120,33 @@ static void test_priv(void)report_prefix_pop (); } +static void test_invalid_address (void ) +{ +void *inv_addr = (void *)-1ull ; + +report_prefix_push ("invalid address" ); + +report_prefix_push ("sske" ); +expect_pgm_int (); +set_storage_key (inv_addr,0 ,0 ); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_push ("iske" ); +expect_pgm_int (); +get_storage_key (inv_addr); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_push ("rrbe" ); +expect_pgm_int (); +reset_reference_bit (inv_addr); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_pop (); +} +int main (void ) {report_prefix_push ("skey" );
@@ -128,6 +155,7 @@ int main(void) goto done; }test_priv (); +test_invalid_address ();test_set ();test_set_mb ();test_chg ();
Signature · 1 line
2.31.1
Quoted 3 lines · David Hildenbrand
... used to be broken in TCG, so let's add a very simple test for SSKE and ISKE. In order to test RRBE as well, introduce a helper to call the machine instruction.
Reviewed-by Janosch Frank <[email protected]>
Quoted 77 lines
Signed-off-by David Hildenbrand <[email protected]>--- lib/s390x/asm/mem.h | 12 ++++++++++++ s390x/skey.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)lib/s390x/asm/mem.h +12
-0@@ -50,6 +50,18 @@ static inline unsigned char get_storage_key(void *addr)return skey; } +static inline unsigned char reset_reference_bit (void *addr) +{ +int cc; + + asmvolatile ( +"rrbe 0,%1\n" +"ipm %0\n" +"srl %0,28\n" + :"=d" (cc) :"a" (addr) :"cc" ); +return cc; +} +#define PFMF_FSC_4K 0#define PFMF_FSC_1M 1#define PFMF_FSC_2G 2s390x/skey.c +28
-0@@ -120,6 +120,33 @@ static void test_priv(void)report_prefix_pop (); } +static void test_invalid_address (void ) +{ +void *inv_addr = (void *)-1ull ; + +report_prefix_push ("invalid address" ); + +report_prefix_push ("sske" ); +expect_pgm_int (); +set_storage_key (inv_addr,0 ,0 ); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_push ("iske" ); +expect_pgm_int (); +get_storage_key (inv_addr); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_push ("rrbe" ); +expect_pgm_int (); +reset_reference_bit (inv_addr); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_pop (); +} +int main (void ) {report_prefix_push ("skey" );@@ -128,6 +155,7 @@ int main(void) goto done; }test_priv (); +test_invalid_address ();test_set ();test_set_mb ();test_chg ();
Quoted 5 lines · On Fri, 3 Sep 2021 18:25:37 +0200 David Hildenbrand <[email protected]> wrote:
... used to be broken in TCG, so let's add a very simple test for SSKE and ISKE. In order to test RRBE as well, introduce a helper to call the machine instruction.
Signed-off-by David Hildenbrand <[email protected]>
Maybe consider testing rrbm too, but anyway:
Reviewed-by Claudio Imbrenda <[email protected]>
Quoted 74 lines
--- lib/s390x/asm/mem.h | 12 ++++++++++++ s390x/skey.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)lib/s390x/asm/mem.h +12
-0@@ -50,6 +50,18 @@ static inline unsigned char get_storage_key(void *addr)return skey; } +static inline unsigned char reset_reference_bit (void *addr) +{ +int cc; + + asmvolatile ( +"rrbe 0,%1\n" +"ipm %0\n" +"srl %0,28\n" + :"=d" (cc) :"a" (addr) :"cc" ); +return cc; +} +#define PFMF_FSC_4K 0#define PFMF_FSC_1M 1#define PFMF_FSC_2G 2s390x/skey.c +28
-0@@ -120,6 +120,33 @@ static void test_priv(void)report_prefix_pop (); } +static void test_invalid_address (void ) +{ +void *inv_addr = (void *)-1ull ; + +report_prefix_push ("invalid address" ); + +report_prefix_push ("sske" ); +expect_pgm_int (); +set_storage_key (inv_addr,0 ,0 ); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_push ("iske" ); +expect_pgm_int (); +get_storage_key (inv_addr); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_push ("rrbe" ); +expect_pgm_int (); +reset_reference_bit (inv_addr); +check_pgm_int_code (PGM_INT_CODE_ADDRESSING ); +report_prefix_pop (); + +report_prefix_pop (); +} +int main (void ) {report_prefix_push ("skey" );@@ -128,6 +155,7 @@ int main(void) goto done; }test_priv (); +test_invalid_address ();test_set ();test_set_mb ();test_chg ();