Skip to content

Commit 1d7bb2b

Browse files
committed
Merge tag 'hyperv-next-signed-20240916' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
Pull Hyper-V updates from Wei Liu: - Optimize boot time by concurrent execution of hv_synic_init() (Saurabh Sengar) - Use helpers to read control registers in hv_snp_boot_ap() (Yosry Ahmed) - Add memory allocation check in hv_fcopy_start (Zhu Jun) * tag 'hyperv-next-signed-20240916' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux: tools/hv: Add memory allocation check in hv_fcopy_start x86/hyperv: use helpers to read control registers in hv_snp_boot_ap() Drivers: hv: vmbus: Optimize boot time by concurrent execution of hv_synic_init()
2 parents 3a7101e + 94e86b1 commit 1d7bb2b

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

arch/x86/hyperv/ivm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ int hv_snp_boot_ap(u32 cpu, unsigned long start_ip)
321321

322322
vmsa->efer = native_read_msr(MSR_EFER);
323323

324-
asm volatile("movq %%cr4, %%rax;" : "=a" (vmsa->cr4));
325-
asm volatile("movq %%cr3, %%rax;" : "=a" (vmsa->cr3));
326-
asm volatile("movq %%cr0, %%rax;" : "=a" (vmsa->cr0));
324+
vmsa->cr4 = native_read_cr4();
325+
vmsa->cr3 = __native_read_cr3();
326+
vmsa->cr0 = native_read_cr0();
327327

328328
vmsa->xcr0 = 1;
329329
vmsa->g_pat = HV_AP_INIT_GPAT_DEFAULT;

drivers/hv/vmbus_drv.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,13 @@ static irqreturn_t vmbus_percpu_isr(int irq, void *dev_id)
13061306
return IRQ_HANDLED;
13071307
}
13081308

1309+
static void vmbus_percpu_work(struct work_struct *work)
1310+
{
1311+
unsigned int cpu = smp_processor_id();
1312+
1313+
hv_synic_init(cpu);
1314+
}
1315+
13091316
/*
13101317
* vmbus_bus_init -Main vmbus driver initialization routine.
13111318
*
@@ -1316,7 +1323,8 @@ static irqreturn_t vmbus_percpu_isr(int irq, void *dev_id)
13161323
*/
13171324
static int vmbus_bus_init(void)
13181325
{
1319-
int ret;
1326+
int ret, cpu;
1327+
struct work_struct __percpu *works;
13201328

13211329
ret = hv_init();
13221330
if (ret != 0) {
@@ -1355,12 +1363,32 @@ static int vmbus_bus_init(void)
13551363
if (ret)
13561364
goto err_alloc;
13571365

1366+
works = alloc_percpu(struct work_struct);
1367+
if (!works) {
1368+
ret = -ENOMEM;
1369+
goto err_alloc;
1370+
}
1371+
13581372
/*
13591373
* Initialize the per-cpu interrupt state and stimer state.
13601374
* Then connect to the host.
13611375
*/
1362-
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online",
1363-
hv_synic_init, hv_synic_cleanup);
1376+
cpus_read_lock();
1377+
for_each_online_cpu(cpu) {
1378+
struct work_struct *work = per_cpu_ptr(works, cpu);
1379+
1380+
INIT_WORK(work, vmbus_percpu_work);
1381+
schedule_work_on(cpu, work);
1382+
}
1383+
1384+
for_each_online_cpu(cpu)
1385+
flush_work(per_cpu_ptr(works, cpu));
1386+
1387+
/* Register the callbacks for possible CPU online/offline'ing */
1388+
ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN, "hyperv/vmbus:online",
1389+
hv_synic_init, hv_synic_cleanup);
1390+
cpus_read_unlock();
1391+
free_percpu(works);
13641392
if (ret < 0)
13651393
goto err_alloc;
13661394
hyperv_cpuhp_online = ret;

tools/hv/hv_fcopy_uio_daemon.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ static int hv_fcopy_start(struct hv_start_fcopy *smsg_in)
296296
file_name = (char *)malloc(file_size * sizeof(char));
297297
path_name = (char *)malloc(path_size * sizeof(char));
298298

299+
if (!file_name || !path_name) {
300+
free(file_name);
301+
free(path_name);
302+
syslog(LOG_ERR, "Can't allocate memory for file name and/or path name");
303+
return HV_E_FAIL;
304+
}
305+
299306
wcstoutf8(file_name, (__u16 *)in_file_name, file_size);
300307
wcstoutf8(path_name, (__u16 *)in_path_name, path_size);
301308

0 commit comments

Comments
 (0)