GithubHelp home page GithubHelp logo

Comments (7)

fslongjin avatar fslongjin commented on September 13, 2024

Me too. my qemu version is

QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.17)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

from virtio-drivers.

fslongjin avatar fslongjin commented on September 13, 2024

This issue is a bit magical; after adding #[inline(never)] to the can_pop function in VirtQueue under src/queue.rs, the test case can running normally. Or here:

while !self.can_pop() {
            info!("add_notify_wait_pop: can_pop=false");
            spin_loop();
        }

By adding an output log statement, it runs normally. I suspect it might be due to a lack of volatile read?

I modified codes in VirtQueue and other structs, make these variables volatile and the bug solved. I'll PR later.

from virtio-drivers.

qwandor avatar qwandor commented on September 13, 2024

I don't think volatile access should be necessary for the used ring (e.g. in VirtQueue::can_pop), because it is shared memory not MMIO. My guess would be that we're missing a read barrier somewhere, which is allowing the compiler (or possibly the CPU?) to reorder memory access in a way that gives incorrect values.

from virtio-drivers.

fslongjin avatar fslongjin commented on September 13, 2024

I don't think volatile access should be necessary for the used ring (e.g. in VirtQueue::can_pop), because it is shared memory not MMIO. My guess would be that we're missing a read barrier somewhere, which is allowing the compiler (or possibly the CPU?) to reorder memory access in a way that gives incorrect values.

Maybe you are right.

Despite the test case of riscv in virtio-drivers can run properly, I have another test case which can not run properly yet.

My test case is in s-mode, sv39, rv64. In my test case the virtio-blk-mmio(legacy) hungs, and virtio-blk-mmio(modern) reports 'not ready' when it read blocks.

But the virtio net driver runs well.(both legacy and modern)

I'll try to investigate what happens.

from virtio-drivers.

qwandor avatar qwandor commented on September 13, 2024

After talking to some other people about this, I think the issue is that we should be using atomics for some of these shared memory accesses. I'll send a PR shortly for you to test.

from virtio-drivers.

qwandor avatar qwandor commented on September 13, 2024

@fslongjin Can you test if #128 fixes your issues reliably?

from virtio-drivers.

fslongjin avatar fslongjin commented on September 13, 2024

@fslongjin Can you test if #128 fixes your issues reliably?

sure, I'll test it tomorrow morning~

from virtio-drivers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.