Skip to content
Merged
3 changes: 3 additions & 0 deletions arch/x86/include/asm/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ struct kvm_vcpu_arch {
u64 ia32_misc_enable_msr;
u64 smbase;
u64 smi_count;
bool at_instruction_boundary;
bool tpr_access_reporting;
bool xsaves_enabled;
bool xfd_no_write_intercept;
Expand Down Expand Up @@ -1282,6 +1283,8 @@ struct kvm_vcpu_stat {
u64 nested_run;
u64 directed_yield_attempted;
u64 directed_yield_successful;
u64 preemption_reported;
u64 preemption_other;
u64 guest_mode;
};

Expand Down
2 changes: 2 additions & 0 deletions arch/x86/kvm/svm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4176,6 +4176,8 @@ static int svm_check_intercept(struct kvm_vcpu *vcpu,

static void svm_handle_exit_irqoff(struct kvm_vcpu *vcpu)
{
if (to_svm(vcpu)->vmcb->control.exit_code == SVM_EXIT_INTR)
vcpu->arch.at_instruction_boundary = true;
}

static void svm_sched_in(struct kvm_vcpu *vcpu, int cpu)
Expand Down
1 change: 1 addition & 0 deletions arch/x86/kvm/vmx/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -6631,6 +6631,7 @@ static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu)
return;

handle_interrupt_nmi_irqoff(vcpu, gate_offset(desc));
vcpu->arch.at_instruction_boundary = true;
}

static void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu)
Expand Down
22 changes: 22 additions & 0 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
STATS_DESC_COUNTER(VCPU, nested_run),
STATS_DESC_COUNTER(VCPU, directed_yield_attempted),
STATS_DESC_COUNTER(VCPU, directed_yield_successful),
STATS_DESC_COUNTER(VCPU, preemption_reported),
STATS_DESC_COUNTER(VCPU, preemption_other),
STATS_DESC_ICOUNTER(VCPU, guest_mode)
};

Expand Down Expand Up @@ -4607,6 +4609,19 @@ static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu)
static const u8 preempted = KVM_VCPU_PREEMPTED;
gpa_t gpa = vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS;

/*
* The vCPU can be marked preempted if and only if the VM-Exit was on
* an instruction boundary and will not trigger guest emulation of any
* kind (see vcpu_run). Vendor specific code controls (conservatively)
* when this is true, for example allowing the vCPU to be marked
* preempted if and only if the VM-Exit was due to a host interrupt.
*/
if (!vcpu->arch.at_instruction_boundary) {
vcpu->stat.preemption_other++;
return;
}

vcpu->stat.preemption_reported++;
if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
return;

Expand Down Expand Up @@ -10367,6 +10382,13 @@ static int vcpu_run(struct kvm_vcpu *vcpu)
vcpu->arch.l1tf_flush_l1d = true;

for (;;) {
/*
* If another guest vCPU requests a PV TLB flush in the middle
* of instruction emulation, the rest of the emulation could
* use a stale page translation. Assume that any code after
* this point can start executing an instruction.
*/
vcpu->arch.at_instruction_boundary = false;
if (kvm_vcpu_running(vcpu)) {
r = vcpu_enter_guest(vcpu);
} else {
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/usb/em28xx/em28xx-cards.c
Original file line number Diff line number Diff line change
Expand Up @@ -3838,6 +3838,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
goto err_free;
}

kref_init(&dev->ref);

dev->devno = nr;
dev->model = id->driver_info;
dev->alt = -1;
Expand Down Expand Up @@ -3938,6 +3940,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
}

if (dev->board.has_dual_ts && em28xx_duplicate_dev(dev) == 0) {
kref_init(&dev->dev_next->ref);

dev->dev_next->ts = SECONDARY_TS;
dev->dev_next->alt = -1;
dev->dev_next->is_audio_only = has_vendor_audio &&
Expand Down Expand Up @@ -3992,12 +3996,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
em28xx_write_reg(dev, 0x0b, 0x82);
mdelay(100);
}

kref_init(&dev->dev_next->ref);
}

kref_init(&dev->ref);

request_modules(dev);

/*
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/can/usb/peak_usb/pcan_usb_fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,11 @@ static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
else
memcpy(cfd->data, rm->d, cfd->len);

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));

netdev->stats.rx_packets++;
netdev->stats.rx_bytes += cfd->len;

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));

return 0;
}

Expand Down Expand Up @@ -586,11 +586,11 @@ static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if,
if (!skb)
return -ENOMEM;

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));

netdev->stats.rx_packets++;
netdev->stats.rx_bytes += cf->can_dlc;

peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,6 @@ area_cache_get(struct nfp_cpp *cpp, u32 id,
}

/* Adjust the start address to be cache size aligned */
cache->id = id;
cache->addr = addr & ~(u64)(cache->size - 1);

/* Re-init to the new ID and address */
Expand All @@ -892,6 +891,8 @@ area_cache_get(struct nfp_cpp *cpp, u32 id,
return NULL;
}

cache->id = id;

exit:
/* Adjust offset */
*offset = addr - cache->addr;
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/ethernet/qualcomm/emac/emac-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,7 @@ int emac_mac_tx_buf_send(struct emac_adapter *adpt, struct emac_tx_queue *tx_q,
{
struct emac_tpd tpd;
u32 prod_idx;
int len;

memset(&tpd, 0, sizeof(tpd));

Expand All @@ -1468,9 +1469,10 @@ int emac_mac_tx_buf_send(struct emac_adapter *adpt, struct emac_tx_queue *tx_q,
if (skb_network_offset(skb) != ETH_HLEN)
TPD_TYP_SET(&tpd, 1);

len = skb->len;
emac_tx_fill_tpd(adpt, tx_q, skb, &tpd);

netdev_sent_queue(adpt->netdev, skb->len);
netdev_sent_queue(adpt->netdev, len);

/* Make sure the are enough free descriptors to hold one
* maximum-sized SKB. We need one desc for each fragment,
Expand Down
9 changes: 9 additions & 0 deletions kernel/time/posix-cpu-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,15 @@ void run_posix_cpu_timers(void)

lockdep_assert_irqs_disabled();

/*
* Ensure that release_task(tsk) can't happen while
* handle_posix_cpu_timers() is running. Otherwise, a concurrent
* posix_cpu_timer_del() may fail to lock_task_sighand(tsk) and
* miss timer->it.cpu.firing != 0.
*/
if (tsk->exit_state)
return;

/*
* The fast path checks that there are no expired thread or thread
* group timers. If that's so, just return.
Expand Down
4 changes: 2 additions & 2 deletions net/core/devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -4541,7 +4541,7 @@ static int devlink_param_get(struct devlink *devlink,
const struct devlink_param *param,
struct devlink_param_gset_ctx *ctx)
{
if (!param->get)
if (!param->get || devlink->reload_failed)
return -EOPNOTSUPP;
return param->get(devlink, param->id, ctx);
}
Expand All @@ -4550,7 +4550,7 @@ static int devlink_param_set(struct devlink *devlink,
const struct devlink_param *param,
struct devlink_param_gset_ctx *ctx)
{
if (!param->set)
if (!param->set || devlink->reload_failed)
return -EOPNOTSUPP;
return param->set(devlink, param->id, ctx);
}
Expand Down
2 changes: 2 additions & 0 deletions net/ipv4/igmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
rv = 1;
} else if (im) {
if (src_addr) {
spin_lock_bh(&im->lock);
for (psf = im->sources; psf; psf = psf->sf_next) {
if (psf->sf_inaddr == src_addr)
break;
Expand All @@ -2747,6 +2748,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
im->sfcount[MCAST_EXCLUDE];
else
rv = im->sfcount[MCAST_EXCLUDE] != 0;
spin_unlock_bh(&im->lock);
} else
rv = 1; /* unspecified source; tentatively allow */
}
Expand Down