Re: [hatari-devel] Code execution on reset within the emulated Atari |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Code execution on reset within the emulated Atari
- From: Uwe Seimet <Uwe.Seimet@xxxxxxxxx>
- Date: Fri, 19 Jul 2024 12:01:41 +0200
- Arc-authentication-results: i=1; strato.com; arc=none; dkim=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1721383319; s=strato-dkim-0002; d=strato.com; h=In-Reply-To:References:Message-ID:Subject:To:From:Date:Cc:Date:From: Subject:Sender; bh=biO3sDS7SZlf/7bLfah8IZSs/EdD00BU54QDYuTCEYQ=; b=q+/tSJ7EoOAQ4kpO+MjHnqd5GDcr/8WarKwvgaNkUJ39LKOcenYCxSDzZneufqybUs aEAmniTQZ4hnmgwmXhBF45A87Xxq9VLJYkvZldsufhxZ6fIJAK+pLAi5hHvCFZhQAuh0 VMZHDk7Q2fWoCoz8mxj3yw3MTMzwgROYAESPSjUtqzNx0pFnQewSKsBfkLbFqJNnWApn V5GvoXGZkolePXYmCBhD7nqBj5poWi4k2YIfbPySnoyebTR1yXvDC08yO1ezZE3FePsw w21MAZCTk6SU5ZldXLuweQduiN80eoqMia8RvHjsusC6DX3kYbkaZxTNVJIcEUybQhAk vzbg==
- Arc-seal: i=1; a=rsa-sha256; t=1721383319; cv=none; d=strato.com; s=strato-dkim-0002; b=bWTvbd5BNr67HmmtSqMg7qgnpqgorENlW6uhF/8Y+F5JOKr+fyNDfEdgaX9bM0StO7 MFgxJPvz01AGso6cwlfZd3ABcjeYJcKEwP3KXEgDbe+Exc3vAAEIW1Z2wM/oFpTX5San dv3KUfGhK+E/UivnlI6aMwCbcXCExmHiZ3fs3PPFfNL7lHcot3XgX8MQejF2lMOtgY+Z 87xs95ygeI0uo7upu/fX5nrCLevtQgxmVJgQ08MQOXZnwEy7l0VzWrQnQR0+S5V6TiG9 ePBz0fvmWR85haxXXh/Jt524tUTf2K1GrkrEqSLk4wkYxmyry3YCWwYaCwu1b8MYNy/d RsKg==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1721383319; s=strato-dkim-0002; d=seimet.de; h=In-Reply-To:References:Message-ID:Subject:To:From:Date:Cc:Date:From: Subject:Sender; bh=biO3sDS7SZlf/7bLfah8IZSs/EdD00BU54QDYuTCEYQ=; b=qvyR4I7YD9jOwFsKGEULicLVQ4byTKuFWJxBxG4U6bXkvOzRItSJ9FreGjJezjor7d YdPezYHBg1G6gTGU3xfRL+hPKXLQJVdx6jn8R+/4QBH8Mw8J8Zn9JHs7yWCJ06kz2a5b MF+ceCWTCXIe/eq/k2wqmHL/N5q0uUtWPl1j/B21Z3ZMar/R5pxIlopGoRyAyYgWgqsH KCorAYugsc8+wLQwJcIvfBVX2+OdUMFiC3/0aM8M+Ttys/BJZ+aXUHlTNUWufYS22wfE Xm5e/00e5bH1EIVJUewEZe/sVB1hGa01088XfQwzfurd32OpY3ye3ksq2nbJu29M4uEe CAAw==
- Dkim-signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1721383318; s=strato-dkim-0003; d=seimet.de; h=In-Reply-To:References:Message-ID:Subject:To:From:Date:Cc:Date:From: Subject:Sender; bh=biO3sDS7SZlf/7bLfah8IZSs/EdD00BU54QDYuTCEYQ=; b=w9PB2kmKg5qNNxfLEbOUH9vLK5dP6zkb75G1u6XaO+TGLhdxQimIYBSU3mCemeFsKH 1vCowUb2kaIgXb6S+sDw==
> On 19/07/2024 11.54, Uwe Seimet wrote:
> >> On Freitag, 19. Juli 2024 11:18:24 CEST Uwe Seimet wrote:
> >>> As a result you run out of external handles.
> >>
> >> BTW, is that real a problem in practise? Yes, if Hatari does not reset the
> >> nf_scsi driver, those handles will be leaked. But how many handles are open
> >> when that happens? Typically, on linux you can have ~1024 file handles open.
> >
> > nf_scsidrv reserves 32 handles, which usually is sufficient. Increasing
> > the number of handles would just be a work-around, but not a clean solution.
> >
> > I will check whether customreset() can do the work. Currently
> > nf_scsidrv_reset is called in reset.c, but this only works if you reset the
> > emulation externally I assumeA
> > .
> > @Thomas In case customreset() works, the call in reset.c can probably be
> > removed?
>
> Yes, I think so.
Looks as if using customreset() works fine. The attached patch contains the
required changes. Can you please review/merge it? Thank you.
diff --git a/src/cpu/hatari-glue.c b/src/cpu/hatari-glue.c
index 5387e0e3..e4b8e90c 100644
--- a/src/cpu/hatari-glue.c
+++ b/src/cpu/hatari-glue.c
@@ -27,6 +27,7 @@ const char HatariGlue_fileid[] = "Hatari hatari-glue.c";
#include "psg.h"
#include "mfp.h"
#include "fdc.h"
+#include "nf_scsidrv.h"
#include "memorySnapShot.h"
#include "sysdeps.h"
@@ -68,6 +69,11 @@ void customreset(void)
/* Reset the FDC */
FDC_Reset ( false );
+
+#if defined(__linux__)
+ /* Reset the native SCSI Driver */
+ nf_scsidrv_reset();
+#endif
}
diff --git a/src/reset.c b/src/reset.c
index bb477c54..0ae38e29 100644
--- a/src/reset.c
+++ b/src/reset.c
@@ -42,7 +42,6 @@ const char Reset_fileid[] = "Hatari reset.c";
#include "falcon/dsp.h"
#include "debugcpu.h"
#include "debugdsp.h"
-#include "nf_scsidrv.h"
/*-----------------------------------------------------------------------*/
/**
@@ -118,10 +117,6 @@ static int Reset_ST(bool bCold)
Midi_Reset();
-#if defined(__linux__)
- nf_scsidrv_reset();
-#endif
-
/* Start HBL, Timer B and VBL interrupts with a 0 cycle delay */
Video_StartInterrupts( 0 );