/*
 * Copyright 2016, Michael Ellerman, IBM Corp.
 * Licensed under GPLv2.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>

#include <asm/cputable.h>

#include "utils.h"

#define SIZE (64 * 1024)

int test_prot_sao(void)
{
	char *p;

	/* 2.06 or later should support SAO */
	SKIP_IF(!have_hwcap(PPC_FEATURE_ARCH_2_06));

	/*
	 * Ensure we can ask for PROT_SAO.
	 * We can't really verify that it does the right thing, but at least we
	 * confirm the kernel will accept it.
	 */
	p = mmap(NULL, SIZE, PROT_READ | PROT_WRITE | PROT_SAO,
		 MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
	FAIL_IF(p == MAP_FAILED);

	/* Write to the mapping, to at least cause a fault */
	memset(p, 0xaa, SIZE);

	return 0;
}

int main(void)
{
	return test_harness(test_prot_sao, "prot-sao");
}
form method='get'>
<input type='hidden' name='id' value='5351fbb1bf1413f6024892093528280769ca852f'/><select name='h' onchange='this.form.submit();'>
<option value='emaclite-cleanup'>emaclite-cleanup</option>
<option value='master' selected='selected'>master</option>
<option value='nds-private-remove'>nds-private-remove</option>
<option value='packet-loop-back'>packet-loop-back</option>
<option value='packet-rx-pump-back'>packet-rx-pump-back</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>net-next plumbings</td><td class='sub right'>Tobias Klauser</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/linux/net-next.git/'>summary</a><a href='/cgit.cgi/linux/net-next.git/refs/?id=5351fbb1bf1413f6024892093528280769ca852f'>refs</a><a class='active' href='/cgit.cgi/linux/net-next.git/log/include/trace'>log</a><a href='/cgit.cgi/linux/net-next.git/tree/include/trace?id=5351fbb1bf1413f6024892093528280769ca852f'>tree</a><a href='/cgit.cgi/linux/net-next.git/commit/include/trace?id=5351fbb1bf1413f6024892093528280769ca852f'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/include/trace?id=5351fbb1bf1413f6024892093528280769ca852f'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/include/trace'>
<input type='hidden' name='id' value='5351fbb1bf1413f6024892093528280769ca852f'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=5351fbb1bf1413f6024892093528280769ca852f'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/include?id=5351fbb1bf1413f6024892093528280769ca852f'>include</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/trace?id=5351fbb1bf1413f6024892093528280769ca852f'>trace</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/include/trace?id=5351fbb1bf1413f6024892093528280769ca852f&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>