Some bugfixes and cleanups for s390x, both in the new pci code and

in old code.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJU0MaQAAoJEN7Pa5PG8C+vS58P/ApghtO/fn1Iev7lzrZe3SkK
 +hz/iOS8lKwoztwaD/qEQBXapKdNCZc5U0j+f0SYVB/aeJfhkSNkv61e+0XwxMK3
 0LFwXVvHwauUC1m//rRLlGSyhAfFDRyAOSKZPPggJn4ZvsQFUAY6Ap7EThjzlvQk
 u4bil9wzeonlPGYaVrmCq7FSBuCXwH0ZMMS4wf+/x6gq8kMvhn0Lvl4dvEfDNRd3
 C33V/HiNQHdqr5qr3LIIhxriDR8jDCh7jZgAqStxBqAAq0qeo1OAe6oh+ccTWTCz
 rVbQu3UZJt0a+4EarS3te+BpWg8ZzM4tuOGwunhKpkJMuoC0aT2stpPQB8uPzZav
 0OASRN5J8aClzlQYCLlixIED3KFY4q4b643r+CGnUczPNhL/C0lj/5ly862RnmoP
 HORFxWamCWy1IKiIWiZpr39ubEb853XaaR6MsC6IVozK9q0i4oqifKoiBRyHe02c
 FEyXUJjImS8HV9UoYiIOsWMeZigmdp+9Q7gjl/oPNoUXmLH4Z5YFCAo01uhNOdYd
 Z/5FosrVedC1bvLCrVMLxB+mk/15K4MAXYW1l4g0W/iN+0RA1tdVlxP7FoaLNMyE
 5ZcB3BGIwjiuSNwMMgvkbmcNtkfoR02qHqm8Xotyjn2hJVopZQpaikpi2gkfD7mD
 MF3dPHqfM6lg3gj662t6
 =gJ0f
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20150203' into staging

Some bugfixes and cleanups for s390x, both in the new pci code and
in old code.

# gpg: Signature made Tue 03 Feb 2015 13:01:04 GMT using RSA key ID C6F02FAF
# gpg: Good signature from "Cornelia Huck <huckc@linux.vnet.ibm.com>"
# gpg:                 aka "Cornelia Huck <cornelia.huck@de.ibm.com>"

* remotes/cohuck/tags/s390x-20150203:
  pc-bios/s390-ccw: update binary
  pc-bios/s390-ccw: fix sparse warnings
  s390x/ipl: Improved code indentation in s390_ipl_init()
  s390x/kvm: unknown DIAGNOSE code should give a specification exception
  s390x/kvm: Fix diag-308 register decoding
  s390x/pci: fix dma notifications in rpcit instruction
  s390x/pci: check for invalid function handle
  s390x/pci: avoid sign extension in stpcifc
  s390: Plug memory leak on s390_pci_generate_event() error path

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-02-03 13:19:52 +00:00
commit 007c99fd0f
10 changed files with 53 additions and 45 deletions

View File

@ -62,6 +62,7 @@ typedef struct S390IPLState {
static int s390_ipl_init(SysBusDevice *dev) static int s390_ipl_init(SysBusDevice *dev)
{ {
S390IPLState *ipl = S390_IPL(dev); S390IPLState *ipl = S390_IPL(dev);
uint64_t pentry = KERN_IMAGE_START;
int kernel_size; int kernel_size;
if (!ipl->kernel) { if (!ipl->kernel) {
@ -94,8 +95,8 @@ static int s390_ipl_init(SysBusDevice *dev)
hw_error("could not load bootloader '%s'\n", bios_name); hw_error("could not load bootloader '%s'\n", bios_name);
} }
return 0; return 0;
} else { }
uint64_t pentry = KERN_IMAGE_START;
kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL, kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL,
NULL, 1, ELF_MACHINE, 0); NULL, 1, ELF_MACHINE, 0);
if (kernel_size < 0) { if (kernel_size < 0) {
@ -118,7 +119,7 @@ static int s390_ipl_init(SysBusDevice *dev)
} else { } else {
ipl->start_addr = pentry; ipl->start_addr = pentry;
} }
}
if (ipl->initrd) { if (ipl->initrd) {
ram_addr_t initrd_offset; ram_addr_t initrd_offset;
int initrd_size; int initrd_size;

View File

@ -170,7 +170,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
S390pciState *s = S390_PCI_HOST_BRIDGE( S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL)); object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
if (!s) { if (!s || !fh) {
return NULL; return NULL;
} }
@ -187,7 +187,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh, static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
uint32_t fid, uint64_t faddr, uint32_t e) uint32_t fid, uint64_t faddr, uint32_t e)
{ {
SeiContainer *sei_cont = g_malloc0(sizeof(SeiContainer)); SeiContainer *sei_cont;
S390pciState *s = S390_PCI_HOST_BRIDGE( S390pciState *s = S390_PCI_HOST_BRIDGE(
object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL)); object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
@ -195,6 +195,7 @@ static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
return; return;
} }
sei_cont = g_malloc0(sizeof(SeiContainer));
sei_cont->fh = fh; sei_cont->fh = fh;
sei_cont->fid = fid; sei_cont->fid = fid;
sei_cont->cc = cc; sei_cont->cc = cc;

View File

@ -487,7 +487,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
CPUS390XState *env = &cpu->env; CPUS390XState *env = &cpu->env;
uint32_t fh; uint32_t fh;
S390PCIBusDevice *pbdev; S390PCIBusDevice *pbdev;
ram_addr_t size; hwaddr start, end;
IOMMUTLBEntry entry; IOMMUTLBEntry entry;
MemoryRegion *mr; MemoryRegion *mr;
@ -504,7 +504,8 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
} }
fh = env->regs[r1] >> 32; fh = env->regs[r1] >> 32;
size = env->regs[r2 + 1]; start = env->regs[r2];
end = start + env->regs[r2 + 1];
pbdev = s390_pci_find_dev_by_fh(fh); pbdev = s390_pci_find_dev_by_fh(fh);
@ -515,15 +516,18 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
} }
mr = pci_device_iommu_address_space(pbdev->pdev)->root; mr = pci_device_iommu_address_space(pbdev->pdev)->root;
entry = mr->iommu_ops->translate(mr, env->regs[r2], 0); while (start < end) {
entry = mr->iommu_ops->translate(mr, start, 0);
if (!entry.translated_addr) { if (!entry.translated_addr) {
setcc(cpu, ZPCI_PCI_LS_ERR); setcc(cpu, ZPCI_PCI_LS_ERR);
goto out; goto out;
} }
entry.addr_mask = size - 1;
memory_region_notify_iommu(mr, entry); memory_region_notify_iommu(mr, entry);
start += entry.addr_mask + 1;
}
setcc(cpu, ZPCI_PCI_LS_OK); setcc(cpu, ZPCI_PCI_LS_OK);
out: out:
return 0; return 0;
@ -784,10 +788,10 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr); stq_p(&fib.aisb, pbdev->routes.adapter.summary_addr);
stq_p(&fib.fmb_addr, pbdev->fmb_addr); stq_p(&fib.fmb_addr, pbdev->fmb_addr);
data = (pbdev->isc << 28) | (pbdev->noi << 16) | data = ((uint32_t)pbdev->isc << 28) | ((uint32_t)pbdev->noi << 16) |
(pbdev->routes.adapter.ind_offset << 8) | (pbdev->sum << 7) | ((uint32_t)pbdev->routes.adapter.ind_offset << 8) |
pbdev->routes.adapter.summary_offset; ((uint32_t)pbdev->sum << 7) | pbdev->routes.adapter.summary_offset;
stw_p(&fib.data, data); stl_p(&fib.data, data);
if (pbdev->fh >> ENABLE_BIT_OFFSET) { if (pbdev->fh >> ENABLE_BIT_OFFSET) {
fib.fc |= 0x80; fib.fc |= 0x80;

Binary file not shown.

View File

@ -33,7 +33,7 @@ typedef struct ResetInfo {
uint32_t ipl_continue; uint32_t ipl_continue;
} ResetInfo; } ResetInfo;
ResetInfo save; static ResetInfo save;
static void jump_to_IPL_2(void) static void jump_to_IPL_2(void)
{ {
@ -80,7 +80,7 @@ static void jump_to_IPL_code(uint64_t address)
*/ */
static unsigned char _bprs[8*1024]; /* guessed "max" ECKD sector size */ static unsigned char _bprs[8*1024]; /* guessed "max" ECKD sector size */
const int max_bprs_entries = sizeof(_bprs) / sizeof(ExtEckdBlockPtr); static const int max_bprs_entries = sizeof(_bprs) / sizeof(ExtEckdBlockPtr);
static inline void verify_boot_info(BootInfo *bip) static inline void verify_boot_info(BootInfo *bip)
{ {

View File

@ -15,7 +15,7 @@
#include "virtio.h" #include "virtio.h"
typedef uint64_t block_number_t; typedef uint64_t block_number_t;
#define NULL_BLOCK_NR 0xffffffffffffffff #define NULL_BLOCK_NR 0xffffffffffffffffULL
#define FREE_SPACE_FILLER '\xAA' #define FREE_SPACE_FILLER '\xAA'

View File

@ -13,7 +13,7 @@
char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE))); char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
uint64_t boot_value; uint64_t boot_value;
struct subchannel_id blk_schid = { .one = 1 }; static struct subchannel_id blk_schid = { .one = 1 };
/* /*
* Priniciples of Operations (SA22-7832-09) chapter 17 requires that * Priniciples of Operations (SA22-7832-09) chapter 17 requires that

View File

@ -51,6 +51,8 @@ void disabled_wait(void);
/* main.c */ /* main.c */
void virtio_panic(const char *string); void virtio_panic(const char *string);
void write_subsystem_identification(void); void write_subsystem_identification(void);
extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
extern uint64_t boot_value;
/* sclp-ascii.c */ /* sclp-ascii.c */
void sclp_print(const char *string); void sclp_print(const char *string);

View File

@ -11,7 +11,7 @@
#include "s390-ccw.h" #include "s390-ccw.h"
#include "virtio.h" #include "virtio.h"
struct vring block; static struct vring block;
static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE))); static char chsc_page[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));

View File

@ -1046,7 +1046,7 @@ static void kvm_handle_diag_308(S390CPU *cpu, struct kvm_run *run)
uint64_t r1, r3; uint64_t r1, r3;
cpu_synchronize_state(CPU(cpu)); cpu_synchronize_state(CPU(cpu));
r1 = (run->s390_sieic.ipa & 0x00f0) >> 8; r1 = (run->s390_sieic.ipa & 0x00f0) >> 4;
r3 = run->s390_sieic.ipa & 0x000f; r3 = run->s390_sieic.ipa & 0x000f;
handle_diag_308(&cpu->env, r1, r3); handle_diag_308(&cpu->env, r1, r3);
} }
@ -1091,7 +1091,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)
break; break;
default: default:
DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code); DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code);
r = -1; enter_pgmcheck(cpu, PGM_SPECIFICATION);
break; break;
} }