Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"There is hopeful symbolism in the fact that flags do not wave in a vacuum." -- Arthur C. Clarke


devel / comp.os.msdos.djgpp / Re: Error handling in __djgpp_nearptr_enable()

SubjectAuthor
* Re: Error handling in __djgpp_nearptr_enable()Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com]
`- Re: Error handling in __djgpp_nearptr_enable()Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com]

1
Re: Error handling in __djgpp_nearptr_enable()

<86plvo2j0r.fsf@gnu.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=482&group=comp.os.msdos.djgpp#482

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 21 Mar 2024 06:31:34 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Recipient: dj@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
mime-version; bh=dsivDusxaaxjzrXgmaG3xi9w950gkHwXRZa0hn0gloQ=; b=e34zAb8Je+Kk
kPcZ9vqzxBcw4tV1MORgHQRJY2krKLQvmK00YOVprY5sAt60sofDOhHFjZtv0Ell0FasZKKhNCHMK
yI87gFkvCDA3hUQZ1Lv0S78A51zfqXHMrSnhke4w4cafUCeb4k1pM4MZNo50ifTLd5tK6cSnTXGa+
JhLpJhSRNEOG1u+Nf0q9i4JzmPyrgm/Qtj7OHqLj0X9ANk+KyJJxVlmFHlpuvBYljvPAgwL5ZOTSh
yB4DB4xrr0fz5/Oh0WL5E+qOqWwX2L/e0I9MZsBx5ETRnDR5e94XljdSodVR94wd9cmQnwRGMUkoV
luvtgAwzqxrnCGv11jSwdw==;
Date: Thu, 21 Mar 2024 08:31:16 +0200
Message-Id: <86plvo2j0r.fsf@gnu.org>
From: djg...@delorie.com (Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com])
To: Pali <pali@pali.im>, "Charles Sandmann" <cwsdpmi@earthlink.net>
Cc: dj@delorie.com, sezeroz@gmail.com, djgpp@delorie.com
In-Reply-To: <20240320203330.clmkn2s4rr4obq4u@pali> (message from Pali on Wed,
20 Mar 2024 21:33:30 +0100)
Subject: Re: Error handling in __djgpp_nearptr_enable()
References: <20240309111216.fetp6m34nbe6u63y@pali> <20240320203330.clmkn2s4rr4obq4u@pali>
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 78
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-Bgey72uhh4kcBrcpIkBiqhQRQQaxXbvxQ7Y2AOYOHD0cOn5Gunkigy0jvCuyQP83sffE5+bpXf3lsNi!nY9MErdF9d6tEWduZ5VaXdBue80qHzdqEzXRchN0TMdm
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Eli Zaretskii (eliz@ - Thu, 21 Mar 2024 06:31 UTC

> Date: Wed, 20 Mar 2024 21:33:30 +0100
> From: Pali <pali@pali.im>
> Cc: djgpp@delorie.com
>
> Hello, I observed strange issue that __djgpp_nearptr_enable() function
> when running in NTVDM on Windows XP, on failure let segment limit in
> some undefined/intermediate state.
>
> Test case:
>
> #include <stdio.h>
> #include <dpmi.h>
> #include <go32.h>
> #include <sys/nearptr.h>
> #include <sys/exceptn.h>
>
> int main() {
> unsigned long addr;
> if (__dpmi_get_segment_base_address(_my_ds(), &addr) == 0)
> printf("OLD BASE: 0x%lx\n", addr);
> printf("OLD LIMIT: 0x%lx\n", __dpmi_get_segment_limit(_my_ds()));
> printf("CALLING __djgpp_nearptr_enable()\n");
> if (__djgpp_nearptr_enable())
> printf("SUCCESS\n");
> else
> printf("FAILED\n");
> if (__dpmi_get_segment_base_address(_my_ds(), &addr) == 0)
> printf("NEW BASE: 0x%lx\n", addr);
> printf("NEW LIMIT: 0x%lx\n", __dpmi_get_segment_limit(_my_ds()));
> return 0;
> }
>
> It prints:
>
> OLD BASE: 0x29e0000
> OLD LIMIT: 0x9ffff
> CALLING __djgpp_nearptr_enable()
> FAILED
> NEW BASE: 0x29e0000
> NEW LIMIT: 0x7d60ffff
>
> I know that Windows NT kernel does not allow userspace to create a
> segment with access to kernel memory space (above 0x7fff0000 limit).
> So failure from the __djgpp_nearptr_enable() call in NTVDM is expected.
> But I was not expecting that DJGPP in some cases may let segment limit
> in some intermediate state.
>
> What about following DJGPP change? I think it can improve failure
> behavior of __djgpp_nearptr_enable() when 4 GB DS limit is not allowed.
>
> --- src/libc/pc_hw/nearptr/nearptr.c
> +++ src/libc/pc_hw/nearptr/nearptr.c
> @@ -14,7 +14,10 @@ int __djgpp_nearptr_enable(void)
> {
> if(!__dpmi_set_segment_limit(_my_ds(), 0xffffffffU)) {
> if(__dpmi_get_segment_limit(_my_ds()) != 0xffffffffU)
> + {
> + __dpmi_set_segment_limit(_my_ds(), __djgpp_selector_limit | 0xfff);
> return 0; /* We set it but DPMI ignored/truncated it */
> + }
> __dpmi_set_segment_limit(__djgpp_ds_alias, 0xffffffffU);
> __dpmi_set_segment_limit(_my_cs(), 0xffffffffU);
> _crt0_startup_flags |= _CRT0_FLAG_NEARPTR;

What are the implications of this change, in plain English, in
particular for DPMI hosts other than NTVDM? (It would be best to
actually test this with at least the popular hosts, including CWSDPMI
and perhaps also versions of Windows newer than XP that still support
DPMI in a reasonable enough manner that allows running |DJGPP
programs.)

I'm CC'ing Charles, in the hope that he is available and can comment
on this.

Btw, the DJGPP FAQ explicitly says that __djgpp_nearptr_enable fails
on Windows NT family (i.e. with NTVDM). So strictly speaking, a
program that calls __djgpp_nearptr_enable in that case is shooting
itself in the foot...

Re: Error handling in __djgpp_nearptr_enable()

<86frvqsnv8.fsf@gnu.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=495&group=comp.os.msdos.djgpp#495

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!news.neodome.net!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 12 Apr 2024 13:37:56 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Recipient: dj@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
mime-version; bh=8Z1HBwarYNvEmf50zhtlJ7xL6JCleJZhEvgLWGDwDLQ=; b=Pvs37ue0+7mb
zBoT2Mrc8kxx94NsDnknzqxCHYKBfFPa3JEzlAJdFdMh6UWb81K1yZJnX63jbaU4At33KEFJPOBoL
unmkaTOGFUHLLPKQsR3hHkJPe7erWqbYGbS9sG1X1E5822yR0MPm9M5o4UsiPCd8KPkHaIXNU2VA4
6AS038ej1TXTh+NQO/5f8Pqz8adz9xYRiKkKqZ0uHUPVx06lHugCV2ejp9dybA6Eu864c+rNU0xu5
2O2MdN5Ds9kyQiYT29zF+pDZ/3VtdE719aJ/kJfyuPta3PBTHmB1kmmd8Ojr9r0oFhAGZvXSgqyk4
63wxjCFg/xOZeZoLhoz0Cw==;
Date: Fri, 12 Apr 2024 16:37:47 +0300
Message-Id: <86frvqsnv8.fsf@gnu.org>
From: djg...@delorie.com (Eli Zaretskii (eliz@gnu.org) [via djgpp@delorie.com])
To: Pali <pali@pali.im>
Cc: cwsdpmi@earthlink.net, dj@delorie.com, sezeroz@gmail.com,
djgpp@delorie.com
In-Reply-To: <20240321174923.hc5xu6iulkakf54w@pali> (message from Pali on Thu,
21 Mar 2024 18:49:23 +0100)
Subject: Re: Error handling in __djgpp_nearptr_enable()
References: <20240309111216.fetp6m34nbe6u63y@pali>
<20240320203330.clmkn2s4rr4obq4u@pali>
<86plvo2j0r.fsf@gnu.org> <20240321174923.hc5xu6iulkakf54w@pali>
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 119
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-ndJp5t2m4XP0KnOKa9BOGby6gDWb8M6K0gC/M+d2V7mnlKjM8MyZUKW5ibbJyiDcKkuGE72I7JH7TDf!T/zUI8q/3h/F1ipZ8D0ttNdeU8E6S+xo5EZXjXbPUJXI
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 7520
 by: Eli Zaretskii (eliz@ - Fri, 12 Apr 2024 13:37 UTC

> Date: Thu, 21 Mar 2024 18:49:23 +0100
> From: Pali <pali@pali.im>
> Cc: Charles Sandmann <cwsdpmi@earthlink.net>, dj@delorie.com,
> sezeroz@gmail.com, djgpp@delorie.com
>
> On Thursday 21 March 2024 08:31:16 Eli Zaretskii wrote:
> > > Hello, I observed strange issue that __djgpp_nearptr_enable() function
> > > when running in NTVDM on Windows XP, on failure let segment limit in
> > > some undefined/intermediate state.
> > >
> > > Test case:
> > >
> > > #include <stdio.h>
> > > #include <dpmi.h>
> > > #include <go32.h>
> > > #include <sys/nearptr.h>
> > > #include <sys/exceptn.h>
> > >
> > > int main() {
> > > unsigned long addr;
> > > if (__dpmi_get_segment_base_address(_my_ds(), &addr) == 0)
> > > printf("OLD BASE: 0x%lx\n", addr);
> > > printf("OLD LIMIT: 0x%lx\n", __dpmi_get_segment_limit(_my_ds()));
> > > printf("CALLING __djgpp_nearptr_enable()\n");
> > > if (__djgpp_nearptr_enable())
> > > printf("SUCCESS\n");
> > > else
> > > printf("FAILED\n");
> > > if (__dpmi_get_segment_base_address(_my_ds(), &addr) == 0)
> > > printf("NEW BASE: 0x%lx\n", addr);
> > > printf("NEW LIMIT: 0x%lx\n", __dpmi_get_segment_limit(_my_ds()));
> > > return 0;
> > > }
> > >
> > > It prints:
> > >
> > > OLD BASE: 0x29e0000
> > > OLD LIMIT: 0x9ffff
> > > CALLING __djgpp_nearptr_enable()
> > > FAILED
> > > NEW BASE: 0x29e0000
> > > NEW LIMIT: 0x7d60ffff
> > >
> > > I know that Windows NT kernel does not allow userspace to create a
> > > segment with access to kernel memory space (above 0x7fff0000 limit).
> > > So failure from the __djgpp_nearptr_enable() call in NTVDM is expected.
> > > But I was not expecting that DJGPP in some cases may let segment limit
> > > in some intermediate state.
> > >
> > > What about following DJGPP change? I think it can improve failure
> > > behavior of __djgpp_nearptr_enable() when 4 GB DS limit is not allowed.
> > >
> > > --- src/libc/pc_hw/nearptr/nearptr.c
> > > +++ src/libc/pc_hw/nearptr/nearptr.c
> > > @@ -14,7 +14,10 @@ int __djgpp_nearptr_enable(void)
> > > {
> > > if(!__dpmi_set_segment_limit(_my_ds(), 0xffffffffU)) {
> > > if(__dpmi_get_segment_limit(_my_ds()) != 0xffffffffU)
> > > + {
> > > + __dpmi_set_segment_limit(_my_ds(), __djgpp_selector_limit | 0xfff);
> > > return 0; /* We set it but DPMI ignored/truncated it */
> > > + }
> > > __dpmi_set_segment_limit(__djgpp_ds_alias, 0xffffffffU);
> > > __dpmi_set_segment_limit(_my_cs(), 0xffffffffU);
> > > _crt0_startup_flags |= _CRT0_FLAG_NEARPTR;
> >
> > What are the implications of this change, in plain English, in
> > particular for DPMI hosts other than NTVDM?
>
> __djgpp_nearptr_enable() first tries to change DS limit to 4GB. If it
> fails then function returns error back to the client. If it success then
> it checks if DS limit is really set to 4GB. If the DS limit is not 4GB
> then function returns error back to the client (return 0; in above
> snipped).
>
> My change above does following: If DS limit is not 4GB then it is reset
> back to the previous value (used before trying to change it to 4GB) and
> after that returns error back to the client (return 0;).
>
> > (It would be best to
> > actually test this with at least the popular hosts, including CWSDPMI
> > and perhaps also versions of Windows newer than XP that still support
> > DPMI in a reasonable enough manner that allows running |DJGPP
> > programs.)
>
> This change does not affect CWSDPMI, because CWSDPMI supports setting DS
> limit to 4GB and hence this code path is not executed.
>
> Also it does not affect any other DPMI host which return failure "on
> failure" and success "on success".
>
> Normally DPMI host should return error if it reject request for changing
> DS limit. But NTVDM is somehow special there, it neither reject request,
> nor accept it. Instead it changes DS limit to the value which is below
> the linear address 0x7fff0000; and returns success to the client. This
> is a reason why DJGPP here has that check if DS limit was really set to
> 4GB.
>
> My change improve the situation here, independently of the failure
> reason (either __dpmi_set_segment_limit() failed or DPMI host returned
> success but not set limit to 4GB), the previous DS limit is not
> modified when function fails.
>
> So if application calls __djgpp_nearptr_enable(), it can ensure that on
> success the limit is 4GB and on failure the limit is not changed at all.
>
> > I'm CC'ing Charles, in the hope that he is available and can comment
> > on this.
> >
> > Btw, the DJGPP FAQ explicitly says that __djgpp_nearptr_enable fails
> > on Windows NT family (i.e. with NTVDM). So strictly speaking, a
> > program that calls __djgpp_nearptr_enable in that case is shooting
> > itself in the foot...
>
> The NTVDM behavior is well documented and it is known that it does not
> allow to access linear memory above 0x7fff0000. And application does
> not know if is running under NTVDM or other DPMI host.

OK, I've now installed this.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor