Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Weird qemu-nvmm problem



On Wed, 11 Mar 2020 at 17:45, Maxime Villard <max%m00nbsd.net@localhost> wrote:
>
> Please CC me for issues related to NVMM, there is a number of lists where
> I'm not subscribed.

I thought about it, but my presumption was that the problem is with
something I haven't done properly...

>
> My understanding is that this commit is the cause (CC ad@):
>
>         https://mail-index.netbsd.org/source-changes/2019/12/06/msg111617.html

Perhaps; I can say, that since early December I've had many occasions
my Windows guests have been working OK; also my OmniOS guest -which I
initially  could not boot after the installation - was able to run
without any problems on the 29th of February; now I can't boot it at
all.

>
> NVMM reschedules the thread when the SPCF_SHOULDYIELD flag is set. But
> after this change the flag never gets set, so the rescheduling never
> occurs, and NVMM is stuck with running the guest forever unless a signal
> is caught in the emulator thread.
>
> The test program below shows the difference. On NetBSD-9 you have many
> "resched", as expected. On NetBSD-current you have none.

As you say, I don't get any output from your program on -current from
yesterday.

>
> Andrew, can you have a look? There is a good dozen of places that use
> SPCF_SHOULDYIELD for reschedulings, and they too may potentially be buggy
> now.
>
> Thanks,
> Maxime
>
>
>
> ---------------------------------------------------------------------------
>
> /*
>  * # gcc -o test test.c -lnvmm
>  * # ./test
>  */
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <sys/mman.h>
> #include <fcntl.h>
> #include <nvmm.h>
> #include <stdint.h>
> #include <string.h>
>
> int main()
> {
>         uint8_t instr[] = { 0xEB, 0xFE };
>         struct nvmm_machine mach;
>         struct nvmm_vcpu vcpu;
>         uintptr_t hva;
>
>         nvmm_init();
>         nvmm_machine_create(&mach);
>         nvmm_vcpu_create(&mach, 0, &vcpu);
>
>         hva = (uintptr_t)mmap(NULL, 4096, PROT_READ|PROT_WRITE,
>             MAP_ANON|MAP_PRIVATE, -1, 0);
>         nvmm_hva_map(&mach, hva, 4096);
>         nvmm_gpa_map(&mach, hva, 0xFFFF0000, 4096, PROT_READ|PROT_EXEC);
>
>         memcpy((void *)hva, instr, sizeof(instr));
>
>         nvmm_vcpu_getstate(&mach, &vcpu, NVMM_X64_STATE_GPRS);
>         vcpu.state->gprs[NVMM_X64_GPR_RIP] = 0;
>         nvmm_vcpu_setstate(&mach, &vcpu, NVMM_X64_STATE_GPRS);
>
>         while (1) {
>                 printf("looping\n");
>                 nvmm_vcpu_run(&mach, &vcpu);
>
>                 switch (vcpu.exit->reason) {
>                 case NVMM_VCPU_EXIT_NONE:
>                         printf("resched\n");
>                         break;
>                 default:
>                         printf("unknown: %d\n", vcpu.exit->reason);
>                         break;
>                 }
>         }
> }

Thanks,

Chavdar


-- 
----


Home | Main Index | Thread Index | Old Index