Skip to content

Commit f10e7b9

Browse files
committed
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-6.2-20211109' into staging
ppc patch queue for 2021-11-09 Here's the latest set of ppc related patches for qemu-6.2, which I hope will squeeze in just barely before the hard freeze. This set includes a change to MAINTAINERS moving maintainership of ppc from myself and Greg Kurz to Cédric le Goater and Daniel Henrique Barboza. So, I expect this to be my last pull request as ppc maintainer. It's been great, but it's time I moved onto other things. Apart from that, this patchset is mostly a lot of updates to TCG implementations of ISA 3.1 (POWER10) instructions from the El Dorado team. There are also a handful of other fixes. # gpg: Signature made Tue 09 Nov 2021 05:14:33 AM CET # gpg: using RSA key 75F46586AE61A66CC44E87DC6C38CACA20D9B392 # gpg: Good signature from "David Gibson <[email protected]>" [full] # gpg: aka "David Gibson (kernel.org) <[email protected]>" [unknown] # gpg: aka "David Gibson (Red Hat) <[email protected]>" [full] # gpg: aka "David Gibson (ozlabs.org) <[email protected]>" [full] * remotes/dgibson/tags/ppc-for-6.2-20211109: (54 commits) spapr_numa.c: FORM2 table handle nodes with no distance info target/ppc, hw/ppc: Change maintainers target/ppc: cntlzdm/cnttzdm implementation without brcond target/ppc: Implement lxvkq instruction target/ppc: Implement xxblendvb/xxblendvh/xxblendvw/xxblendvd instructions target/ppc: implemented XXSPLTIDP instruction target/ppc: Implemented XXSPLTIW using decodetree target/ppc: implemented XXSPLTI32DX target/ppc: moved XXSPLTIB to using decodetree target/ppc: moved XXSPLTW to using decodetree target/ppc: added the instructions PLXVP and PSTXVP target/ppc: added the instructions PLXV and PSTXV target/ppc: added the instructions LXVPX and STXVPX target/ppc: added the instructions LXVP and STXVP target/ppc: moved stxvx and lxvx from legacy to decodtree target/ppc: moved stxv and lxv from legacy to decodtree target/ppc: receive high/low as argument in get/set_cpu_vsr target/ppc: Introduce REQUIRE_VSX macro target/ppc: Implement Vector Extract Double to VSR using GPR index insns target/ppc: Move vinsertb/vinserth/vinsertw/vinsertd to decodetree ... Signed-off-by: Richard Henderson <[email protected]>
2 parents 114f3c8 + 71e6fae commit f10e7b9

25 files changed

+2171
-1297
lines changed

MAINTAINERS

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ F: hw/openrisc/
262262
F: tests/tcg/openrisc/
263263

264264
PowerPC TCG CPUs
265-
M: David Gibson <[email protected]>
266-
M: Greg Kurz <[email protected]>
265+
M: Cédric Le Goater <[email protected]>
266+
M: Daniel Henrique Barboza <[email protected]>
267+
R: David Gibson <[email protected]>
268+
R: Greg Kurz <[email protected]>
267269
268270
S: Maintained
269271
F: target/ppc/
@@ -382,8 +384,10 @@ F: target/mips/kvm*
382384
F: target/mips/sysemu/
383385

384386
PPC KVM CPUs
385-
M: David Gibson <[email protected]>
386-
M: Greg Kurz <[email protected]>
387+
M: Cédric Le Goater <[email protected]>
388+
M: Daniel Henrique Barboza <[email protected]>
389+
R: David Gibson <[email protected]>
390+
R: Greg Kurz <[email protected]>
387391
S: Maintained
388392
F: target/ppc/kvm.c
389393

@@ -1321,8 +1325,10 @@ F: include/hw/rtc/m48t59.h
13211325
F: tests/avocado/ppc_prep_40p.py
13221326

13231327
sPAPR
1324-
M: David Gibson <[email protected]>
1325-
M: Greg Kurz <[email protected]>
1328+
M: Cédric Le Goater <[email protected]>
1329+
M: Daniel Henrique Barboza <[email protected]>
1330+
R: David Gibson <[email protected]>
1331+
R: Greg Kurz <[email protected]>
13261332
13271333
S: Maintained
13281334
F: hw/*/spapr*
@@ -1382,6 +1388,8 @@ F: include/hw/pci-host/mv64361.h
13821388

13831389
Virtual Open Firmware (VOF)
13841390
M: Alexey Kardashevskiy <[email protected]>
1391+
R: Cédric Le Goater <[email protected]>
1392+
R: Daniel Henrique Barboza <[email protected]>
13851393
R: David Gibson <[email protected]>
13861394
R: Greg Kurz <[email protected]>
13871395

hw/ppc/pegasos2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "hw/qdev-properties.h"
2424
#include "sysemu/reset.h"
2525
#include "sysemu/runstate.h"
26+
#include "sysemu/qtest.h"
2627
#include "hw/boards.h"
2728
#include "hw/loader.h"
2829
#include "hw/fw-path-provider.h"
@@ -199,7 +200,7 @@ static void pegasos2_init(MachineState *machine)
199200
if (!pm->vof) {
200201
warn_report("Option -kernel may be ineffective with -bios.");
201202
}
202-
} else if (pm->vof) {
203+
} else if (pm->vof && !qtest_enabled()) {
203204
warn_report("Using Virtual OpenFirmware but no -kernel option.");
204205
}
205206

hw/ppc/pnv_pnor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void pnv_pnor_update(PnvPnor *s, int offset, int size)
3636
int offset_end;
3737
int ret;
3838

39-
if (s->blk) {
39+
if (!s->blk || !blk_is_writable(s->blk)) {
4040
return;
4141
}
4242

hw/ppc/spapr_numa.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,24 @@ static void spapr_numa_FORM2_write_rtas_tables(SpaprMachineState *spapr,
546546
* NUMA nodes, but QEMU adds the default NUMA node without
547547
* adding the numa_info to retrieve distance info from.
548548
*/
549-
if (src == dst) {
550-
distance_table[i++] = NUMA_DISTANCE_MIN;
551-
continue;
549+
distance_table[i] = numa_info[src].distance[dst];
550+
if (distance_table[i] == 0) {
551+
/*
552+
* In case QEMU adds a default NUMA single node when the user
553+
* did not add any, or where the user did not supply distances,
554+
* the value will be 0 here. Populate the table with a fallback
555+
* simple local / remote distance.
556+
*/
557+
if (src == dst) {
558+
distance_table[i] = NUMA_DISTANCE_MIN;
559+
} else {
560+
distance_table[i] = numa_info[src].distance[dst];
561+
if (distance_table[i] < NUMA_DISTANCE_MIN) {
562+
distance_table[i] = NUMA_DISTANCE_DEFAULT;
563+
}
564+
}
552565
}
553-
554-
distance_table[i++] = numa_info[src].distance[dst];
566+
i++;
555567
}
556568
}
557569

include/libdecnumber/decNumber.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,16 @@
116116
decNumber * decNumberFromUInt32(decNumber *, uint32_t);
117117
decNumber *decNumberFromInt64(decNumber *, int64_t);
118118
decNumber *decNumberFromUInt64(decNumber *, uint64_t);
119+
decNumber *decNumberFromInt128(decNumber *, uint64_t, int64_t);
120+
decNumber *decNumberFromUInt128(decNumber *, uint64_t, uint64_t);
119121
decNumber * decNumberFromString(decNumber *, const char *, decContext *);
120122
char * decNumberToString(const decNumber *, char *);
121123
char * decNumberToEngString(const decNumber *, char *);
122124
uint32_t decNumberToUInt32(const decNumber *, decContext *);
123125
int32_t decNumberToInt32(const decNumber *, decContext *);
124126
int64_t decNumberIntegralToInt64(const decNumber *dn, decContext *set);
127+
void decNumberIntegralToInt128(const decNumber *dn, decContext *set,
128+
uint64_t *plow, uint64_t *phigh);
125129
uint8_t * decNumberGetBCD(const decNumber *, uint8_t *);
126130
decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);
127131

include/libdecnumber/decNumberLocal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
/* Shared lookup tables */
100100
extern const uByte DECSTICKYTAB[10]; /* re-round digits if sticky */
101-
extern const uLong DECPOWERS[19]; /* powers of ten table */
101+
extern const uLong DECPOWERS[20]; /* powers of ten table */
102102
/* The following are included from decDPD.h */
103103
extern const uShort DPD2BIN[1024]; /* DPD -> 0-999 */
104104
extern const uShort BIN2DPD[1000]; /* 0-999 -> DPD */

include/qemu/host-utils.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,42 @@ static inline bool umul64_overflow(uint64_t x, uint64_t y, uint64_t *ret)
590590
#endif
591591
}
592592

593+
/*
594+
* Unsigned 128x64 multiplication.
595+
* Returns true if the result got truncated to 128 bits.
596+
* Otherwise, returns false and the multiplication result via plow and phigh.
597+
*/
598+
static inline bool mulu128(uint64_t *plow, uint64_t *phigh, uint64_t factor)
599+
{
600+
#if defined(CONFIG_INT128) && \
601+
(__has_builtin(__builtin_mul_overflow) || __GNUC__ >= 5)
602+
bool res;
603+
__uint128_t r;
604+
__uint128_t f = ((__uint128_t)*phigh << 64) | *plow;
605+
res = __builtin_mul_overflow(f, factor, &r);
606+
607+
*plow = r;
608+
*phigh = r >> 64;
609+
610+
return res;
611+
#else
612+
uint64_t dhi = *phigh;
613+
uint64_t dlo = *plow;
614+
uint64_t ahi;
615+
uint64_t blo, bhi;
616+
617+
if (dhi == 0) {
618+
mulu64(plow, phigh, dlo, factor);
619+
return false;
620+
}
621+
622+
mulu64(plow, &ahi, dlo, factor);
623+
mulu64(&blo, &bhi, dhi, factor);
624+
625+
return uadd64_overflow(ahi, blo, phigh) || bhi != 0;
626+
#endif
627+
}
628+
593629
/**
594630
* uadd64_carry - addition with carry-in and carry-out
595631
* @x, @y: addends

libdecnumber/decContext.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ static const Flag *mfctop=(Flag *)&mfcone; /* -> top byte */
5353
const uByte DECSTICKYTAB[10]={1,1,2,3,4,6,6,7,8,9}; /* used if sticky */
5454

5555
/* ------------------------------------------------------------------ */
56-
/* Powers of ten (powers[n]==10**n, 0<=n<=9) */
56+
/* Powers of ten (powers[n]==10**n, 0<=n<=19) */
5757
/* ------------------------------------------------------------------ */
58-
const uLong DECPOWERS[19] = {1, 10, 100, 1000, 10000, 100000, 1000000,
58+
const uLong DECPOWERS[20] = {1, 10, 100, 1000, 10000, 100000, 1000000,
5959
10000000, 100000000, 1000000000, 10000000000ULL, 100000000000ULL,
6060
1000000000000ULL, 10000000000000ULL, 100000000000000ULL, 1000000000000000ULL,
61-
10000000000000000ULL, 100000000000000000ULL, 1000000000000000000ULL, };
61+
10000000000000000ULL, 100000000000000000ULL, 1000000000000000000ULL,
62+
10000000000000000000ULL,};
6263

6364
/* ------------------------------------------------------------------ */
6465
/* decContextClearStatus -- clear bits in current status */

libdecnumber/decNumber.c

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
/* ------------------------------------------------------------------ */
168168

169169
#include "qemu/osdep.h"
170+
#include "qemu/host-utils.h"
170171
#include "libdecnumber/dconfig.h"
171172
#include "libdecnumber/decNumber.h"
172173
#include "libdecnumber/decNumberLocal.h"
@@ -263,6 +264,7 @@ static decNumber * decTrim(decNumber *, decContext *, Flag, Int *);
263264
static Int decUnitAddSub(const Unit *, Int, const Unit *, Int, Int,
264265
Unit *, Int);
265266
static Int decUnitCompare(const Unit *, Int, const Unit *, Int, Int);
267+
static bool mulUInt128ByPowOf10(uLong *, uLong *, uInt);
266268

267269
#if !DECSUBSET
268270
/* decFinish == decFinalize when no subset arithmetic needed */
@@ -462,6 +464,41 @@ decNumber *decNumberFromUInt64(decNumber *dn, uint64_t uin)
462464
return dn;
463465
} /* decNumberFromUInt64 */
464466

467+
decNumber *decNumberFromInt128(decNumber *dn, uint64_t lo, int64_t hi)
468+
{
469+
uint64_t unsig_hi = hi;
470+
if (hi < 0) {
471+
if (lo == 0) {
472+
unsig_hi = -unsig_hi;
473+
} else {
474+
unsig_hi = ~unsig_hi;
475+
lo = -lo;
476+
}
477+
}
478+
479+
decNumberFromUInt128(dn, lo, unsig_hi);
480+
if (hi < 0) {
481+
dn->bits = DECNEG; /* sign needed */
482+
}
483+
return dn;
484+
} /* decNumberFromInt128 */
485+
486+
decNumber *decNumberFromUInt128(decNumber *dn, uint64_t lo, uint64_t hi)
487+
{
488+
uint64_t rem;
489+
Unit *up; /* work pointer */
490+
decNumberZero(dn); /* clean */
491+
if (lo == 0 && hi == 0) {
492+
return dn; /* [or decGetDigits bad call] */
493+
}
494+
for (up = dn->lsu; hi > 0 || lo > 0; up++) {
495+
rem = divu128(&lo, &hi, DECDPUNMAX + 1);
496+
*up = (Unit)rem;
497+
}
498+
dn->digits = decGetDigits(dn->lsu, up - dn->lsu);
499+
return dn;
500+
} /* decNumberFromUInt128 */
501+
465502
/* ------------------------------------------------------------------ */
466503
/* to-int64 -- conversion to int64 */
467504
/* */
@@ -506,6 +543,68 @@ int64_t decNumberIntegralToInt64(const decNumber *dn, decContext *set)
506543
return 0;
507544
} /* decNumberIntegralToInt64 */
508545

546+
/* ------------------------------------------------------------------ */
547+
/* decNumberIntegralToInt128 -- conversion to int128 */
548+
/* */
549+
/* dn is the decNumber to convert. dn is assumed to have been */
550+
/* rounded to a floating point integer value. */
551+
/* set is the context for reporting errors */
552+
/* returns the converted decNumber via plow and phigh */
553+
/* */
554+
/* Invalid is set if the decNumber is a NaN, Infinite or is out of */
555+
/* range for a signed 128 bit integer. */
556+
/* ------------------------------------------------------------------ */
557+
558+
void decNumberIntegralToInt128(const decNumber *dn, decContext *set,
559+
uint64_t *plow, uint64_t *phigh)
560+
{
561+
int d; /* work */
562+
const Unit *up; /* .. */
563+
uint64_t lo = 0, hi = 0;
564+
565+
if (decNumberIsSpecial(dn) || (dn->exponent < 0) ||
566+
(dn->digits + dn->exponent > 39)) {
567+
goto Invalid;
568+
}
569+
570+
up = dn->lsu; /* -> lsu */
571+
572+
for (d = (dn->digits - 1) / DECDPUN; d >= 0; d--) {
573+
if (mulu128(&lo, &hi, DECDPUNMAX + 1)) {
574+
/* overflow */
575+
goto Invalid;
576+
}
577+
if (uadd64_overflow(lo, up[d], &lo)) {
578+
if (uadd64_overflow(hi, 1, &hi)) {
579+
/* overflow */
580+
goto Invalid;
581+
}
582+
}
583+
}
584+
585+
if (mulUInt128ByPowOf10(&lo, &hi, dn->exponent)) {
586+
/* overflow */
587+
goto Invalid;
588+
}
589+
590+
if (decNumberIsNegative(dn)) {
591+
if (lo == 0) {
592+
*phigh = -hi;
593+
*plow = 0;
594+
} else {
595+
*phigh = ~hi;
596+
*plow = -lo;
597+
}
598+
} else {
599+
*plow = lo;
600+
*phigh = hi;
601+
}
602+
603+
return;
604+
605+
Invalid:
606+
decContextSetStatus(set, DEC_Invalid_operation);
607+
} /* decNumberIntegralToInt128 */
509608

510609
/* ------------------------------------------------------------------ */
511610
/* to-scientific-string -- conversion to numeric string */
@@ -7849,6 +7948,38 @@ static Int decGetDigits(Unit *uar, Int len) {
78497948
return digits;
78507949
} /* decGetDigits */
78517950

7951+
/* ------------------------------------------------------------------ */
7952+
/* mulUInt128ByPowOf10 -- multiply a 128-bit unsigned integer by a */
7953+
/* power of 10. */
7954+
/* */
7955+
/* The 128-bit factor composed of plow and phigh is multiplied */
7956+
/* by 10^exp. */
7957+
/* */
7958+
/* plow pointer to the low 64 bits of the first factor */
7959+
/* phigh pointer to the high 64 bits of the first factor */
7960+
/* exp the exponent of the power of 10 of the second factor */
7961+
/* */
7962+
/* If the result fits in 128 bits, returns false and the */
7963+
/* multiplication result through plow and phigh. */
7964+
/* Otherwise, returns true. */
7965+
/* ------------------------------------------------------------------ */
7966+
static bool mulUInt128ByPowOf10(uLong *plow, uLong *phigh, uInt pow10)
7967+
{
7968+
while (pow10 >= ARRAY_SIZE(powers)) {
7969+
if (mulu128(plow, phigh, powers[ARRAY_SIZE(powers) - 1])) {
7970+
/* Overflow */
7971+
return true;
7972+
}
7973+
pow10 -= ARRAY_SIZE(powers) - 1;
7974+
}
7975+
7976+
if (pow10 > 0) {
7977+
return mulu128(plow, phigh, powers[pow10]);
7978+
} else {
7979+
return false;
7980+
}
7981+
}
7982+
78527983
#if DECTRACE | DECCHECK
78537984
/* ------------------------------------------------------------------ */
78547985
/* decNumberShow -- display a number [debug aid] */

0 commit comments

Comments
 (0)