Send inn-workers mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.isc.org/mailman/listinfo/inn-workers
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of inn-workers digest..."
Today's Topics:
1. Re: Capability to integer casts on CheriBSD (Richard Kettlewell)
2. Re: Capability to integer casts on CheriBSD (Julien ?LIE)
3. Re: Capability to integer casts on CheriBSD (Richard Kettlewell)
----------------------------------------------------------------------
Message: 1
Date: Mon, 30 Oct 2023 19:58:07 +0000
From: Richard Kettlewell <[email protected]>
To: [email protected]
Subject: Re: Capability to integer casts on CheriBSD
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 30/10/2023 09:49, Richard Kettlewell wrote:
> ? // Total length of pages
> ? size_t total_length = start+offset + length + end_offset;
^^^^^^^^^^^^
Should be start_offset of course.
> ? return msync(start, total_length, flags);
>
> Totally untested - the calculation should be out into a distinct
> function so it can be unit-tested properly.
ttfn/rjk
------------------------------
Message: 2
Date: Mon, 30 Oct 2023 22:10:27 +0100
From: Julien ?LIE <[email protected]>
To: [email protected]
Subject: Re: Capability to integer casts on CheriBSD
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
Hi Richard,
> The idea of the code in question seems to be to convert region expressed
> by a pointer and length into the slightly wider region containing it
> consisting of whole pages.
Yes, indeed.
And your proposal even optimizes the initial code which always takes an
extra pagesize.
> An alternative approach that does not synthesize any pointers (but still
> relies on a pointer-to-integer conversion):
>
> ? size_t page_mask = pagesize - 1;
>
> ? // Offset of p from start of first page
> ? size_t start_offset = (size_t)p & page_mask;
>
> ? // Start of first page
> ? char *start = p - start_offset;
>
> ? // Offset of (p+length) from start of last page, or 0
> ? // if (p+length) is exactly on a page boundary
> ? size_t end_offset = (start_offset + length) & page_mask;
>
> ? // Offset _backwards_ of (p+length) from end of last page
> ? if(end_offset > 0)
> ??? end_offset = page_mask - end_offset;
I see the idea, thanks.
As for pointer-to-integer conversion, maybe casting to (uintptr_t) could
be of help? I've googled a bit and found out that it is in the C99
standard.
Maybe we could check for its being available via Autoconf
(AC_TYPE_UINTPTR_T macro) and use (uintptr_t) instead of (size_t) if
that's the case?
> ? // Total length of pages
> ? size_t total_length = start_offset + length + end_offset;
I'm unsure total_length always has the right value. If end_offset is 0,
total_length should be pagesize I think. I'll have a look at how to
compute the expected length (multiple of pagesize).
>> icd.c:490:16: error: cast from capability type 'char *' to
>> non-capability, non-address type 'unsigned long' is most likely an
>> error [-Werror,-Wcapability-to-integer-cast]
>> ???????? syslog(L_FATAL, "%s msync failed %s 0x%lx %d %m", LogName,
>> ICDactpath,
>> ??????????????? (unsigned long) ICDactpointer, ICDactsize);
>> ??????????????? ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> That one should be %p. It would already be broken on a platform with
> 32-bit long but 64-bit (or longer) pointers.
Agreed, I'll fix that, thanks.
--
Julien ?LIE
??Vita breuis, ars longa, occasio praeceps, experimentum pericolosum,
iudicium difficile.?? (Hippocrate)
------------------------------
Message: 3
Date: Tue, 31 Oct 2023 08:31:32 +0000
From: Richard Kettlewell <[email protected]>
To: [email protected]
Subject: Re: Capability to integer casts on CheriBSD
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 30/10/2023 21:10, Julien ?LIE wrote:
> Hi Richard,
>
>> The idea of the code in question seems to be to convert region
>> expressed by a pointer and length into the slightly wider region
>> containing it consisting of whole pages.
>
> Yes, indeed.
> And your proposal even optimizes the initial code which always takes an
> extra pagesize.
>
>
>> An alternative approach that does not synthesize any pointers (but
>> still relies on a pointer-to-integer conversion):
>>
>> ?? size_t page_mask = pagesize - 1;
>>
>> ?? // Offset of p from start of first page
>> ?? size_t start_offset = (size_t)p & page_mask;
>>
>> ?? // Start of first page
>> ?? char *start = p - start_offset;
>>
>> ?? // Offset of (p+length) from start of last page, or 0
>> ?? // if (p+length) is exactly on a page boundary
>> ?? size_t end_offset = (start_offset + length) & page_mask;
>>
>> ?? // Offset _backwards_ of (p+length) from end of last page
>> ?? if(end_offset > 0)
>> ???? end_offset = page_mask - end_offset;
>
> I see the idea, thanks.
> As for pointer-to-integer conversion, maybe casting to (uintptr_t) could
> be of help?? I've googled a bit and found out that it is in the C99
> standard
All the sizes are bounded by the size of whatever the containing memory
mapping is, which has to fit in a size_t since that's what the argument
to mmap() was when the mapping was created.
So I don't think uintptr_t will make much difference.
> Maybe we could check for its being available via Autoconf
> (AC_TYPE_UINTPTR_T macro) and use (uintptr_t) instead of (size_t) if
> that's the case?
>
>
>> ?? // Total length of pages
>> ?? size_t total_length = start_offset + length + end_offset;
>
> I'm unsure total_length always has the right value.? If end_offset is 0,
> total_length should be pagesize I think.
Are you sure?
As a concrete example, suppose:
pagesize = 4096
p is at the start of a page
length = 8192
Then:
start_offset = 0
start = p
end_offset = (0+8192)&4095 = 0
total_length = 0+8192+0 = 8192
which is surely what we want.
ttfn/rjk
------------------------------
Subject: Digest Footer
_______________________________________________
inn-workers mailing list
[email protected]
https://lists.isc.org/mailman/listinfo/inn-workers
------------------------------
End of inn-workers Digest, Vol 154, Issue 3
*******************************************