From: Cornelia Huck <cohuck@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH] s390x/tcg: clear local interrupts on reset normal
Date: Fri, 6 Dec 2019 11:27:30 +0100 [thread overview]
Message-ID: <20191206112730.3959e58c.cohuck@redhat.com> (raw)
In-Reply-To: <4939898a-99c6-2257-9f44-3d706190f331@redhat.com>
On Fri, 6 Dec 2019 10:36:40 +0100
David Hildenbrand <david@redhat.com> wrote:
> On 05.12.19 11:38, Cornelia Huck wrote:
> > We neglected to clean up pending interrupts and emergency signals;
> > fix that.
> >
> > Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> > ---
> >
> > Noted while looking at the fixes for the kvm reset handling.
> >
> > We now clear some fields twice in the paths for clear or initial reset;
> > but (a) we already do that for other fields and (b) it does not really
> > hurt. Maybe we should give the cpu structure some love in the future,
> > as it's not always clear whether some fields are tcg only.
> >
> > ---
> > target/s390x/cpu.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> > index 829ce6ad5491..f2572961dc3a 100644
> > --- a/target/s390x/cpu.c
> > +++ b/target/s390x/cpu.c
> > @@ -133,6 +133,9 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
> > case S390_CPU_RESET_NORMAL:
> > env->pfault_token = -1UL;
> > env->bpbc = false;
> > + env->pending_int = 0;
> > + env->external_call_addr = 0;
> > + bitmap_zero(env->emergency_signals, S390_MAX_CPUS);
> > break;
> > default:
> > g_assert_not_reached();
> >
>
> I'd suggest we rework the memsetting instead, now that we always
> "fall through" in this call chain, e.g, something like
Yeah, I did this patch before I applied Janosch's patch that reworks
this function... now it probably makes more sense to do it your way.
>
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index bd39cb54b7..492f0c766d 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -95,12 +95,14 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
>
> switch (type) {
> case S390_CPU_RESET_CLEAR:
> - memset(env, 0, offsetof(CPUS390XState, start_initial_reset_fields));
> + memset(&env->start_clear_reset_fields, 0,
> + offsetof(CPUS390XState, end_clear_reset_fields) -
> + offsetof(CPUS390XState, start_clear_reset_fields));
> /* fall through */
> case S390_CPU_RESET_INITIAL:
> /* initial reset does not clear everything! */
> memset(&env->start_initial_reset_fields, 0,
> - offsetof(CPUS390XState, end_reset_fields) -
> + offsetof(CPUS390XState, end_initial_reset_fields) -
> offsetof(CPUS390XState, start_initial_reset_fields));
>
> /* architectured initial value for Breaking-Event-Address register */
> @@ -123,8 +125,10 @@ static void s390_cpu_reset(CPUState *s, cpu_reset_type type)
> &env->fpu_status);
> /* fall through */
> case S390_CPU_RESET_NORMAL:
> + memset(&env->start_normal_reset_fields, 0,
> + offsetof(CPUS390XState, end_normal_reset_fields) -
> + offsetof(CPUS390XState, start_normal_reset_fields));
> env->pfault_token = -1UL;
> - env->bpbc = false;
> break;
> default:
> g_assert_not_reached();
> diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
> index d2af13b345..fe2ab6b89e 100644
> --- a/target/s390x/cpu.h
> +++ b/target/s390x/cpu.h
> @@ -51,6 +51,9 @@ typedef struct PSW {
> } PSW;
>
> struct CPUS390XState {
> +
> + struct {} start_clear_reset_fields;
> +
> uint64_t regs[16]; /* GP registers */
> /*
> * The floating point registers are part of the vector registers.
> @@ -63,12 +66,11 @@ struct CPUS390XState {
> uint64_t etoken; /* etoken */
> uint64_t etoken_extension; /* etoken extension */
>
> - /* Fields up to this point are not cleared by initial CPU reset */
> + struct {} end_clear_reset_fields;
> struct {} start_initial_reset_fields;
>
> uint32_t fpc; /* floating-point control register */
> uint32_t cc_op;
> - bool bpbc; /* branch prediction blocking */
>
> float_status fpu_status; /* passed to softfloat lib */
>
> @@ -99,10 +101,6 @@ struct CPUS390XState {
>
> uint64_t cregs[16]; /* control registers */
>
> - int pending_int;
> - uint16_t external_call_addr;
> - DECLARE_BITMAP(emergency_signals, S390_MAX_CPUS);
> -
> uint64_t ckc;
> uint64_t cputm;
> uint32_t todpr;
> @@ -114,8 +112,17 @@ struct CPUS390XState {
> uint64_t gbea;
> uint64_t pp;
>
> - /* Fields up to this point are cleared by a CPU reset */
> - struct {} end_reset_fields;
> + struct {} end_initial_reset_fields;
> + struct {} start_normal_reset_fields;
> +
> + /* local interrupt state */
> + int pending_int;
> + uint16_t external_call_addr;
> + DECLARE_BITMAP(emergency_signals, S390_MAX_CPUS);
> +
> + bool bpbc; /* branch prediction blocking */
> +
> + struct {} end_normal_reset_fields;
>
> #if !defined(CONFIG_USER_ONLY)
> uint32_t core_id; /* PoP "CPU address", same as cpu_index */
prev parent reply other threads:[~2019-12-06 15:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-05 10:38 [PATCH] s390x/tcg: clear local interrupts on reset normal Cornelia Huck
2019-12-05 10:56 ` Philippe Mathieu-Daudé
2019-12-05 11:02 ` Cornelia Huck
2019-12-06 9:36 ` David Hildenbrand
2019-12-06 10:27 ` Cornelia Huck [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=20191206112730.3959e58c.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
/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).