2 * POWER Data Stream Control Register (DSCR) fork test
4 * This testcase modifies the DSCR using mtspr, forks and then
5 * verifies that the child process has the correct changed DSCR
8 * When using the privilege state SPR, the instructions such as
9 * mfspr or mtspr are priviledged and the kernel emulates them
10 * for us. Instructions using problem state SPR can be exuecuted
11 * directly without any emulation if the HW supports them. Else
12 * they also get emulated by the kernel.
14 * Copyright 2012, Anton Blanchard, IBM Corporation.
15 * Copyright 2015, Anshuman Khandual, IBM Corporation.
17 * This program is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License version 2 as published
19 * by the Free Software Foundation.
23 int dscr_inherit(void)
25 unsigned long i, dscr = 0;
31 for (i = 0; i < COUNT; i++) {
32 unsigned long cur_dscr, cur_dscr_usr;
45 perror("fork() failed");
50 if (waitpid(pid, &status, 0) == -1) {
51 perror("waitpid() failed");
55 if (!WIFEXITED(status)) {
56 fprintf(stderr, "Child didn't exit cleanly\n");
60 if (WEXITSTATUS(status) != 0) {
61 fprintf(stderr, "Child didn't exit cleanly\n");
65 cur_dscr = get_dscr();
66 if (cur_dscr != dscr) {
67 fprintf(stderr, "Kernel DSCR should be %ld "
68 "but is %ld\n", dscr, cur_dscr);
72 cur_dscr_usr = get_dscr_usr();
73 if (cur_dscr_usr != dscr) {
74 fprintf(stderr, "User DSCR should be %ld "
75 "but is %ld\n", dscr, cur_dscr_usr);
84 int main(int argc, char *argv[])
86 return test_harness(dscr_inherit, "dscr_inherit_test");