Bug fixes

-----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAl+yw3sUHHBib256aW5p
 QHJlZGhhdC5jb20ACgkQv/vSX3jHroMs7Af/c8TxKh4NZkBB4KUYciHxIMvya4OL
 5cVW31EwQdm7Fh9bNfPzi1+UG9FDMS9djgX/wNzhOUjoeeABnDau+G4egzDq0eoo
 I2MrHltLzj49u0aqF9ea28GoNCBEc829hxMWuQJHfXgLhQFCeiFWmBnlR3tvsyRm
 Kkd2/H23XfNK5ijz3rUqgjSY3o8CMXaiiJd+f712jCP457H8tytZoYvImFojGRyi
 BWvXLwGYPXIw4hJpqKI0EpXzdBSTwJgX1iTpg6dGRnr85lhriOgdYbFwJHygGBa+
 ghWkkYmUto/La0DO7XTisuKj5ok6jNplLMkrA3aZNA0/9QwQto5zB3mOOQ==
 =niWB
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging

Bug fixes

# gpg: Signature made Mon 16 Nov 2020 18:22:51 GMT
# gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
# gpg:                issuer "pbonzini@redhat.com"
# gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full]
# gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [full]
# Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
#      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83

* remotes/bonzini-gitlab/tags/for-upstream:
  memory: Skip dirty tracking for un-migratable memory regions
  target/i386: avoid theoretical leak on MCE injection
  scsi-disk: convert more errno values back to SCSI statuses
  util/vfio-helpers.c: Use ram_block_discard_disable() in qemu_vfio_open_pci()
  kvm/i386: Set proper nested state format for SVM

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-11-16 22:29:51 +00:00
commit bce36c6c54
6 changed files with 53 additions and 11 deletions

View File

@ -461,6 +461,25 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
}
error = scsi_sense_buf_to_errno(r->req.sense, sizeof(r->req.sense));
break;
#ifdef CONFIG_LINUX
/* These errno mapping are specific to Linux. For more information:
* - scsi_decide_disposition in drivers/scsi/scsi_error.c
* - scsi_result_to_blk_status in drivers/scsi/scsi_lib.c
* - blk_errors[] in block/blk-core.c
*/
case EBADE:
/* DID_NEXUS_FAILURE -> BLK_STS_NEXUS. */
scsi_req_complete(&r->req, RESERVATION_CONFLICT);
break;
case ENODATA:
/* DID_MEDIUM_ERROR -> BLK_STS_MEDIUM. */
scsi_check_condition(r, SENSE_CODE(READ_ERROR));
break;
case EREMOTEIO:
/* DID_TARGET_FAILURE -> BLK_STS_TARGET. */
scsi_req_complete(&r->req, HARDWARE_ERROR);
break;
#endif
case ENOMEDIUM:
scsi_check_condition(r, SENSE_CODE(NO_MEDIUM));
break;

View File

@ -1806,7 +1806,10 @@ bool memory_region_is_ram_device(MemoryRegion *mr)
uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr)
{
uint8_t mask = mr->dirty_log_mask;
if (global_dirty_log && (mr->ram_block || memory_region_is_iommu(mr))) {
RAMBlock *rb = mr->ram_block;
if (global_dirty_log && ((rb && qemu_ram_is_migratable(rb)) ||
memory_region_is_iommu(mr))) {
mask |= (1 << DIRTY_MEMORY_MIGRATION);
}
return mask;

View File

@ -1,6 +1,7 @@
#include "qemu/osdep.h"
#include "exec/ramlist.h"
#include "exec/cpu-common.h"
#include "exec/memory.h"
void *qemu_ram_get_host_addr(RAMBlock *rb)
{
@ -29,3 +30,8 @@ int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque)
{
return 0;
}
int ram_block_discard_disable(bool state)
{
return 0;
}

View File

@ -908,16 +908,14 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
return;
}
if (recursive) {
need_reset = true;
msg = g_strdup_printf("CPU %d: Previous MCE still in progress, "
"raising triple fault", cs->cpu_index);
}
if (!(cenv->cr[4] & CR4_MCE_MASK)) {
need_reset = true;
msg = g_strdup_printf("CPU %d: MCE capability is not enabled, "
"raising triple fault", cs->cpu_index);
} else if (recursive) {
need_reset = true;
msg = g_strdup_printf("CPU %d: Previous MCE still in progress, "
"raising triple fault", cs->cpu_index);
}
if (need_reset) {

View File

@ -1820,12 +1820,14 @@ int kvm_arch_init_vcpu(CPUState *cs)
env->nested_state = g_malloc0(max_nested_state_len);
env->nested_state->size = max_nested_state_len;
env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX;
if (cpu_has_vmx(env)) {
vmx_hdr = &env->nested_state->hdr.vmx;
vmx_hdr->vmxon_pa = -1ull;
vmx_hdr->vmcs12_pa = -1ull;
env->nested_state->format = KVM_STATE_NESTED_FORMAT_VMX;
vmx_hdr = &env->nested_state->hdr.vmx;
vmx_hdr->vmxon_pa = -1ull;
vmx_hdr->vmcs12_pa = -1ull;
} else {
env->nested_state->format = KVM_STATE_NESTED_FORMAT_SVM;
}
}
}

View File

@ -16,6 +16,7 @@
#include "qapi/error.h"
#include "exec/ramlist.h"
#include "exec/cpu-common.h"
#include "exec/memory.h"
#include "trace.h"
#include "qemu/error-report.h"
#include "standard-headers/linux/pci_regs.h"
@ -494,8 +495,20 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp)
int r;
QEMUVFIOState *s = g_new0(QEMUVFIOState, 1);
/*
* VFIO may pin all memory inside mappings, resulting it in pinning
* all memory inside RAM blocks unconditionally.
*/
r = ram_block_discard_disable(true);
if (r) {
error_setg_errno(errp, -r, "Cannot set discarding of RAM broken");
g_free(s);
return NULL;
}
r = qemu_vfio_init_pci(s, device, errp);
if (r) {
ram_block_discard_disable(false);
g_free(s);
return NULL;
}
@ -837,4 +850,5 @@ void qemu_vfio_close(QEMUVFIOState *s)
close(s->device);
close(s->group);
close(s->container);
ram_block_discard_disable(false);
}