1 /* 2 * POWER Data Stream Control Register (DSCR) SPR test 3 * 4 * This test modifies the DSCR value through both the SPR number 5 * based mtspr instruction and then makes sure that the same is 6 * reflected through mfspr instruction using either of the SPR 7 * numbers. 8 * 9 * When using the privilege state SPR, the instructions such as 10 * mfspr or mtspr are priviledged and the kernel emulates them 11 * for us. Instructions using problem state SPR can be exuecuted 12 * directly without any emulation if the HW supports them. Else 13 * they also get emulated by the kernel. 14 * 15 * Copyright 2013, Anton Blanchard, IBM Corporation. 16 * Copyright 2015, Anshuman Khandual, IBM Corporation. 17 * 18 * This program is free software; you can redistribute it and/or modify it 19 * under the terms of the GNU General Public License version 2 as published 20 * by the Free Software Foundation. 21 */ 22 #include "dscr.h" 23 24 static int check_dscr(char *str) 25 { 26 unsigned long cur_dscr, cur_dscr_usr; 27 28 cur_dscr = get_dscr(); 29 cur_dscr_usr = get_dscr_usr(); 30 if (cur_dscr != cur_dscr_usr) { 31 printf("%s set, kernel get %lx != user get %lx\n", 32 str, cur_dscr, cur_dscr_usr); 33 return 1; 34 } 35 return 0; 36 } 37 38 int dscr_user(void) 39 { 40 int i; 41 42 check_dscr(""); 43 44 for (i = 0; i < COUNT; i++) { 45 set_dscr(i); 46 if (check_dscr("kernel")) 47 return 1; 48 } 49 50 for (i = 0; i < COUNT; i++) { 51 set_dscr_usr(i); 52 if (check_dscr("user")) 53 return 1; 54 } 55 return 0; 56 } 57 58 int main(int argc, char *argv[]) 59 { 60 return test_harness(dscr_user, "dscr_user_test"); 61 } 62