Message ID | 1379945085-29086-8-git-send-email-rth@twiddle.net |
---|---|
State | New |
Headers | show |
On 09/23/2013 04:04 PM, Richard Henderson wrote: > The implementation had been incomplete, as we did not store the > machine type. > > Signed-off-by: Richard Henderson<rth@twiddle.net> > --- > target-s390x/cpu.c | 2 ++ > target-s390x/cpu.h | 14 +++++++++++++- > target-s390x/translate.c | 2 +- > 3 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c > index 01ff49b..d003dcf 100644 > --- a/target-s390x/cpu.c > +++ b/target-s390x/cpu.c > @@ -257,6 +257,8 @@ static void s390_cpu_initfn(Object *obj) > env->facilities[0] |= FAC0_Z9_109; > #endif > > + env->machine_type = 0x20940000; /* ??? Also Z9-109. */ This really wants to be selected by -cpu. > + > if (tcg_enabled()&& !inited) { > inited = true; > s390x_translate_init(); > diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h > index a0bafef..95f9cab 100644 > --- a/target-s390x/cpu.h > +++ b/target-s390x/cpu.h > @@ -197,7 +197,19 @@ typedef struct CPUS390XState { > /* reset does memset(0) up to here */ > uint64_t facilities[2]; > > - int cpu_num; > + union { > + uint64_t cpuid; > + struct { > +#ifdef HOST_WORDS_BIGENDIAN > + uint32_t cpu_num; > + uint32_t machine_type; > +#else > + uint32_t machine_type; > + uint32_t cpu_num; > +#endif Are we guaranteed that we don't need to pack? Also anonymous unions/structs are a gcc extension IIRC. And why do you swap endianness here, but not above when defining the machine_type value? Alex > + }; > + }; > + > uint8_t *storage_keys; > > uint64_t tod_offset; > diff --git a/target-s390x/translate.c b/target-s390x/translate.c > index 192d54e..25a6537 100644 > --- a/target-s390x/translate.c > +++ b/target-s390x/translate.c > @@ -3242,7 +3242,7 @@ static ExitStatus op_stctl(DisasContext *s, DisasOps *o) > static ExitStatus op_stidp(DisasContext *s, DisasOps *o) > { > check_privileged(s); > - tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, cpu_num)); > + tcg_gen_ld_i64(o->out, cpu_env, offsetof(CPUS390XState, cpuid)); > return NO_EXIT; > } >
On 09/30/2013 11:13 AM, Alexander Graf wrote: >> - int cpu_num; >> + union { >> + uint64_t cpuid; >> + struct { >> +#ifdef HOST_WORDS_BIGENDIAN >> + uint32_t cpu_num; >> + uint32_t machine_type; >> +#else >> + uint32_t machine_type; >> + uint32_t cpu_num; >> +#endif > > Are we guaranteed that we don't need to pack? Also anonymous unions/structs are > a gcc extension IIRC. And why do you swap endianness here, but not above when > defining the machine_type value? (1) I can't imagine that we would; such struct/unions are used all over. (2) Sure, but we've so many other gcc extensions I figured it didn't matter. (3) Of course. I want host endianness, not target endianness. r~
On 09/30/2013 09:48 PM, Richard Henderson wrote: > On 09/30/2013 11:13 AM, Alexander Graf wrote: >>> - int cpu_num; >>> + union { >>> + uint64_t cpuid; >>> + struct { >>> +#ifdef HOST_WORDS_BIGENDIAN >>> + uint32_t cpu_num; >>> + uint32_t machine_type; >>> +#else >>> + uint32_t machine_type; >>> + uint32_t cpu_num; >>> +#endif >> Are we guaranteed that we don't need to pack? Also anonymous unions/structs are >> a gcc extension IIRC. And why do you swap endianness here, but not above when >> defining the machine_type value? > (1) I can't imagine that we would; such struct/unions are used all over. *shrug* you're the expert :). > (2) Sure, but we've so many other gcc extensions I figured it didn't matter. Avi complained about it to me in Linux patches. Not sure how much we care in QEMU. > (3) Of course. I want host endianness, not target endianness. Phew. I think I'm slowly starting to grasp what you're trying to do here. Any way you could make this more explicit through shifts and ors and other explicit operations? This feels like too much magic to "just understand on a glimpse" to me. Alex
On 10/01/2013 08:52 AM, Alexander Graf wrote: > On 09/30/2013 09:48 PM, Richard Henderson wrote: >> On 09/30/2013 11:13 AM, Alexander Graf wrote: >>>> - int cpu_num; >>>> + union { >>>> + uint64_t cpuid; >>>> + struct { >>>> +#ifdef HOST_WORDS_BIGENDIAN >>>> + uint32_t cpu_num; >>>> + uint32_t machine_type; >>>> +#else >>>> + uint32_t machine_type; >>>> + uint32_t cpu_num; >>>> +#endif >>> Are we guaranteed that we don't need to pack? Also anonymous unions/structs are >>> a gcc extension IIRC. And why do you swap endianness here, but not above when >>> defining the machine_type value? >> (1) I can't imagine that we would; such struct/unions are used all over. > > *shrug* you're the expert :). > >> (2) Sure, but we've so many other gcc extensions I figured it didn't matter. > > Avi complained about it to me in Linux patches. Not sure how much we care in QEMU. > >> (3) Of course. I want host endianness, not target endianness. > > Phew. I think I'm slowly starting to grasp what you're trying to do here. Any > way you could make this more explicit through shifts and ors and other explicit > operations? This feels like too much magic to "just understand on a glimpse" to > me. Yes, I could arrange for it to be two loads and assembled at runtime. It's not like this insn is used on any hot path... or indeed, apparently more than once in the whole lifetime of the system. r~
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 01ff49b..d003dcf 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -257,6 +257,8 @@ static void s390_cpu_initfn(Object *obj) env->facilities[0] |= FAC0_Z9_109; #endif + env->machine_type = 0x20940000; /* ??? Also Z9-109. */ + if (tcg_enabled() && !inited) { inited = true; s390x_translate_init(); diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index a0bafef..95f9cab 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -197,7 +197,19 @@ typedef struct CPUS390XState { /* reset does memset(0) up to here */ uint64_t facilities[2]; - int cpu_num; + union { + uint64_t cpuid; + struct { +#ifdef HOST_WORDS_BIGENDIAN + uint32_t cpu_num; + uint32_t machine_type; +#else + uint32_t machine_type; + uint32_t cpu_num; +#endif + }; + }; + uint8_t *storage_keys; uint64_t tod_offset; diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 192d54e..25a6537 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -3242,7 +3242,7 @@ static ExitStatus op_stctl(DisasContext *s, DisasOps *o) static ExitStatus op_stidp(DisasContext *s, DisasOps *o) { check_privileged(s); - tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, cpu_num)); + tcg_gen_ld_i64(o->out, cpu_env, offsetof(CPUS390XState, cpuid)); return NO_EXIT; }
The implementation had been incomplete, as we did not store the machine type. Signed-off-by: Richard Henderson <rth@twiddle.net> --- target-s390x/cpu.c | 2 ++ target-s390x/cpu.h | 14 +++++++++++++- target-s390x/translate.c | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-)