lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <99ed8894-9d30-7dac-9826-abf95b9a5e80@huawei.com>
Date:   Wed, 15 Jan 2020 21:49:57 +0800
From:   Zenghui Yu <yuzenghui@...wei.com>
To:     Marc Zyngier <maz@...nel.org>
CC:     Shaokun Zhang <zhangshaokun@...ilicon.com>,
        <kvmarm@...ts.cs.columbia.edu>, <linux-kernel@...r.kernel.org>,
        Eric Auger <eric.auger@...hat.com>,
        James Morse <james.morse@....com>,
        Julien Thierry <julien.thierry.kdev@...il.com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Jason Cooper <jason@...edaemon.net>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Andrew Murray <Andrew.Murray@....com>,
        Robert Richter <rrichter@...vell.com>,
        "Tangnianyao (ICT)" <tangnianyao@...wei.com>
Subject: Re: [PATCH v3 29/32] KVM: arm64: GICv4.1: Allow SGIs to switch
 between HW and SW interrupts

Hi Marc,

On 2020/1/15 21:32, Marc Zyngier wrote:
> On 2020-01-15 03:49, Zenghui Yu wrote:
>> Hi,
>>
>> On 2020/1/15 10:49, Shaokun Zhang wrote:
>>> Hi Marc, [This is from Nianyao]
>>>
>>> On 2019/12/24 19:10, Marc Zyngier wrote:
>>>> In order to let a guest buy in the new, active-less SGIs, we
>>>> need to be able to switch between the two modes.
>>>>
>>>> Handle this by stopping all guest activity, transfer the state
>>>> from one mode to the other, and resume the guest.
>>>>
>>>> Signed-off-by: Marc Zyngier <maz@...nel.org>
>>>> ---
>>
>> [...]
>>
>>>> diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c
>>>> index c2fcde104ea2..063785fd2dc7 100644
>>>> --- a/virt/kvm/arm/vgic/vgic-v4.c
>>>> +++ b/virt/kvm/arm/vgic/vgic-v4.c
>>>> @@ -97,6 +97,102 @@ static irqreturn_t vgic_v4_doorbell_handler(int 
>>>> irq, void *info)
>>>>       return IRQ_HANDLED;
>>>>   }
>>>>   +static void vgic_v4_sync_sgi_config(struct its_vpe *vpe, struct 
>>>> vgic_irq *irq)
>>>> +{
>>>> +    vpe->sgi_config[irq->intid].enabled    = irq->enabled;
>>>> +    vpe->sgi_config[irq->intid].group     = irq->group;
>>>> +    vpe->sgi_config[irq->intid].priority    = irq->priority;
>>>> +}
>>>> +
>>>> +static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu)
>>>> +{
>>>> +    struct its_vpe *vpe = &vcpu->arch.vgic_cpu.vgic_v3.its_vpe;
>>>> +    int i;
>>>> +
>>>> +    /*
>>>> +     * With GICv4.1, every virtual SGI can be directly injected. So
>>>> +     * let's pretend that they are HW interrupts, tied to a host
>>>> +     * IRQ. The SGI code will do its magic.
>>>> +     */
>>>> +    for (i = 0; i < VGIC_NR_SGIS; i++) {
>>>> +        struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, i);
>>>> +        struct irq_desc *desc;
>>>> +        int ret;
>>>> +
>>>> +        if (irq->hw) {
>>>> +            vgic_put_irq(vcpu->kvm, irq);
>>>> +            continue;
>>>> +        }
>>>> +
>>>> +        irq->hw = true;
>>>> +        irq->host_irq = irq_find_mapping(vpe->sgi_domain, i);
>>>
>>> I think we need to check whether irq_find_mapping returns 0.
>>>
>>>> +        vgic_v4_sync_sgi_config(vpe, irq);
>>>> +        /*
>>>> +         * SGIs are initialised as disabled. Enable them if
>>>> +         * required by the rest of the VGIC init code.
>>>> +         */
>>>> +        desc = irq_to_desc(irq->host_irq);
>>>> +        ret = irq_domain_activate_irq(irq_desc_get_irq_data(desc),
>>>> +                          false);
>>>
>>> If irq->host_irq is not valid , in irq_domain_activate_irq, it will 
>>> trigger NULL pointer
>>> dereference in host kernel.
>>> I meet a problem here. When hw support GIC4.1, and host kernel is 
>>> started with
>>> kvm-arm.vgic_v4_enable=0, starting a virtual machine will trigger 
>>> NULL pointer
>>> dereference in host.
>>
>> I think the thing is that we should _not_ try to configure vSGIs at all
>> if kvm-arm.vgic_v4_enable=0 (which indicates we don't allow use of the
>> GICv4 of direct injection).
>>
>> We currently set kvm_vgic_global_state.has_gicv4_1 to true if HW support
>> GICv4.1, regardless whatever the gicv4_enable is (see patch#23 -
>> vgic_v3_probe).  I think this is what actually needs fixing.
> 
> Yes, my point exactly. I've pushed out a potential fix [1], and I'd be
> grateful if you could let me know whether that fixes it for you.

I haven't had the appropriate HW yet.. Nianyao or Shaokun can help to
test it tomorrow, I think.

> 
> Thanks,
> 
>          M.
> 
> [1] 
> https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/commit/?h=irq/gic-v4.1-devel&id=b82c2ee1d3fef66fb85793965c344260f618219d 

Anyway, this looks good to me.


Thanks,
Zenghui

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ