From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: linux-sgx@vger.kernel.org
Subject: Re: [PATCH for_v22] selftests/x86/sgx: Ensure SECS base (ELRANGE) is naturally aligned
Date: Sat, 10 Aug 2019 14:22:16 +0300 [thread overview]
Message-ID: <20190810112216.u2dolvtkv62dyeno@linux.intel.com> (raw)
In-Reply-To: <20190810003051.15712-1-sean.j.christopherson@intel.com>
On Fri, Aug 09, 2019 at 05:30:51PM -0700, Sean Christopherson wrote:
> Manually align ELRANGE now that the kernel doesn't automatically do so
> for SGX mappings. To guarantee mmap() returns a region that can be
> naturally aligned, temporarily map 2x the enclave size and do fancy
> arithmetic to naturally align the base.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Thank you.
I fine-tuned the calculations a bit:
area = mmap(NULL, secs->size * 2, PROT_NONE, MAP_SHARED, dev_fd, 0);
if (area == MAP_FAILED) {
perror("mmap");
return false;
}
secs->base = ((uint64_t)area + secs->size - 1) & ~(secs->size - 1);
munmap(area, secs->base - (uint64_t)area);
munmap((void *)(secs->base + secs->size),
(uint64_t)area + secs->size - secs->base);
/Jarkko
prev parent reply other threads:[~2019-08-10 11:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-10 0:30 [PATCH for_v22] selftests/x86/sgx: Ensure SECS base (ELRANGE) is naturally aligned Sean Christopherson
2019-08-10 0:39 ` Jethro Beekman
2019-08-10 11:23 ` Jarkko Sakkinen
2019-08-15 12:26 ` Jarkko Sakkinen
2019-08-10 11:22 ` Jarkko Sakkinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190810112216.u2dolvtkv62dyeno@linux.intel.com \
--to=jarkko.sakkinen@linux.intel.com \
--cc=linux-sgx@vger.kernel.org \
--cc=sean.j.christopherson@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).