On Thu, Oct 01, 2015 at 08:48:17PM +0100, Peter Maydell wrote: > On 1 October 2015 at 19:44, Edgar E. Iglesias <edgar.igles...@xilinx.com> > wrote: > > On Wed, Sep 23, 2015 at 09:55:05AM -0700, Peter Maydell wrote: > >> This isn't right -- the XN bit controls executability and the > >> S2AP bits don't affect it at all. I think you want: > >> > >> int prot_rw = 0; > >> if (s2ap & 1) { > >> prot_rw |= PAGE_READ; > >> } > >> if (s2ap & 2) { > >> prot_rw |= PAGE_WRITE; > >> } > >> if (!xn) { > >> prot_rw |= PAGE_EXEC; > >> } > > > > > > Thanks, this was the stuff I was worried about when we talked about it > > last time. I've got the following now which seems to be the same as > > you suggest: > > > > static int get_S2prot(CPUARMState *env, int s2ap, int xn) > > { > > int prot; > > > > prot = s2ap & 1 ? PAGE_READ : 0; > > prot |= s2ap & 2 ? PAGE_WRITE : 0; > > if (!xn) { > > prot |= PAGE_EXEC; > > } > > return prot; > > } > > Yep, that's the right logic, though it seems a bit odd not > to consistently use either 'if' or '?:' for all 3 bits.
OK, that's true, I'll change it to all ifs. Thanks, Edgar