12456fdf7SNico Boehr /* SPDX-License-Identifier: GPL-2.0-only */ 22456fdf7SNico Boehr /* 32456fdf7SNico Boehr * Snippet used by the sie-dat.c test to verify paging without MSO/MSL 42456fdf7SNico Boehr * 52456fdf7SNico Boehr * Copyright (c) 2023 IBM Corp 62456fdf7SNico Boehr * 72456fdf7SNico Boehr * Authors: 82456fdf7SNico Boehr * Nico Boehr <nrb@linux.ibm.com> 92456fdf7SNico Boehr */ 102456fdf7SNico Boehr #include <libcflat.h> 112456fdf7SNico Boehr #include <asm-generic/page.h> 12c39f40c3SThomas Huth #include <asm/mem.h> 13*37f185edSNina Schoetterl-Glausch #include <snippet-exit.h> 142456fdf7SNico Boehr #include "sie-dat.h" 152456fdf7SNico Boehr 162456fdf7SNico Boehr static uint8_t test_pages[GUEST_TEST_PAGE_COUNT * PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); 172456fdf7SNico Boehr main(void)182456fdf7SNico Boehrint main(void) 192456fdf7SNico Boehr { 202456fdf7SNico Boehr uint8_t *invalid_ptr; 212456fdf7SNico Boehr 222456fdf7SNico Boehr memset(test_pages, 0, sizeof(test_pages)); 232456fdf7SNico Boehr /* tell the host the page's physical address (we're running DAT off) */ 242456fdf7SNico Boehr force_exit_value((uint64_t)test_pages); 252456fdf7SNico Boehr 262456fdf7SNico Boehr /* write some value to the page so the host can verify it */ 272456fdf7SNico Boehr for (size_t i = 0; i < GUEST_TEST_PAGE_COUNT; i++) 282456fdf7SNico Boehr test_pages[i * PAGE_SIZE] = 42 + i; 292456fdf7SNico Boehr 302456fdf7SNico Boehr /* indicate we've written all pages */ 312456fdf7SNico Boehr force_exit(); 322456fdf7SNico Boehr 332456fdf7SNico Boehr /* the first unmapped address */ 34c39f40c3SThomas Huth invalid_ptr = OPAQUE_PTR(GUEST_TOTAL_PAGE_COUNT * PAGE_SIZE); 352456fdf7SNico Boehr *invalid_ptr = 42; 362456fdf7SNico Boehr 372456fdf7SNico Boehr /* indicate we've written the non-allowed page (should never get here) */ 382456fdf7SNico Boehr force_exit(); 392456fdf7SNico Boehr 402456fdf7SNico Boehr return 0; 412456fdf7SNico Boehr } 42