Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1911515pxb; Mon, 23 Aug 2021 07:32:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJfLKwmAsZF/NJ6hhDdwcMb2lyasjYDbW8LmXZl+QBfm3Y0rLL0dQTuLb61ZdXUa3LeVIt X-Received: by 2002:a05:6402:3486:: with SMTP id v6mr2350976edc.21.1629729154913; Mon, 23 Aug 2021 07:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629729154; cv=none; d=google.com; s=arc-20160816; b=tiEpqJS4SABuI9rrmu0yBgUjuaaobSyKoELO34hkiuXI++9iSO1z4F0jfonvc0G02v Nj9RGeX+lICEJoDkQ4hqX30W+TQUhl2lwGdQYRH4m90+GWYPy1H5W7+UIc9SXzVwS0Uz KLP2FiKl1YqgSks3CAHQCPqljuZqSKQfPhC+nmwhNV7h3yDzeI0Fhg6+DuhziJXE9jul tYzbtp+oSoveps029Mh8hGjsyX4kUI7MepnV5b+Htu78DYdIz1A+HPPB+z6Izfvbn2y4 VstngqMeomtlsOXGWvgIaYmKFWMe/B2Df96Q4ZHwmQ5rcxjbXCHB9FJ2r6XsJjwJs+Rx hxtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/eh0h+3M1/EQ0xIV9YAbz4kQ7bCgK+sDeXRpZ7vSkn8=; b=1G61sIjhGjnkEiuT7+kpBizpkPNnV9vk8YBToF4yImnifObNgb5AMUut33ssOWK+9T xn2Rl1RKWN5sC1mJI98UJsFZ2Ii1mpbzdgZrtib88SaDGlo7EWQyTbHBrknI+lL+VtlS 7YbyFs4aaOtkREHF/e3Wxu9bH2rL390qDz38JlzR8euo7FqYeZbj39HSzTjcrdJXFtae BBi0qRW/WRGAkYCpkqAIaclYHR4B2Y06tYM6jw+3GRgbz3QLAr/vN7+CXBubVtjmbrvh F2atVJOSdeVkpW+H3fVNjJdVX8SPKvQndS1HdcnbFwWK9rOF/zAJCDY9HkLHZrXKoNlY +zsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JMJTaAER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b90si14296673edf.484.2021.08.23.07.32.09; Mon, 23 Aug 2021 07:32:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JMJTaAER; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbhHWObY (ORCPT + 99 others); Mon, 23 Aug 2021 10:31:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59313 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbhHWObY (ORCPT ); Mon, 23 Aug 2021 10:31:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629729041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=/eh0h+3M1/EQ0xIV9YAbz4kQ7bCgK+sDeXRpZ7vSkn8=; b=JMJTaAER38Uk3dX6pzxSN8HqOksaNTN2MCm4XvxLOM3qj//maPZF+s6IzGG6MxnCriDjsI DIg9LQR83CxhUhKwPu+korkjEFhb9ScXfqY3ciuSRtR2nfRxk2GQgFj3cX7Kqhv/LzkV17 jQlaopH1CV7R/UQvFANtQ+xbtNII7BQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-5EZgzsSeOBOG_UOi-Z3umg-1; Mon, 23 Aug 2021 10:30:39 -0400 X-MC-Unique: 5EZgzsSeOBOG_UOi-Z3umg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 852AE87D542; Mon, 23 Aug 2021 14:30:37 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.195.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5A602707F; Mon, 23 Aug 2021 14:30:29 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , "Dr. David Alan Gilbert" , Nitesh Narayan Lal , linux-kernel@vger.kernel.org Subject: [PATCH v2 0/4] KVM: Various fixes and improvements around kicking vCPUs Date: Mon, 23 Aug 2021 16:30:24 +0200 Message-Id: <20210823143028.649818-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series is a continuation to Sean's "[PATCH 0/2] VM: Fix a benign race in kicking vCPUs" work and v2 for my "KVM: Optimize kvm_make_vcpus_request_mask() a bit"/"KVM: x86: Fix stack-out-of-bounds memory access from ioapic_write_indirect()" patchset. Changes since v1: - Drop inappropriate added 'likely' from kvm_make_vcpus_request_mask [Sean] - Keep get_cpu()/put_cpu() and pass 'current_cpu' parameter to kvm_make_vcpu_request() as a minor optimization [Sean] From Sean: "Fix benign races when kicking vCPUs where the task doing the kicking can consume a stale vcpu->cpu. The races are benign because of the impliciations of task migration with respect to interrupts and being in guest mode, but IMO they're worth fixing if only as an excuse to document the flows. Patch 2 is a tangentially related cleanup to prevent future me from trying to get rid of the NULL check on the cpumask parameters, which _looks_ like it can't ever be NULL, but has a subtle edge case due to the way CONFIG_CPUMASK_OFFSTACK=y handles cpumasks." Patch3 is a minor optimization for kvm_make_vcpus_request_mask() for big guests. Patch4 fixes a real problem with ioapic_write_indirect() KVM does out-of-bounds access to stack memory. Sean Christopherson (2): KVM: Clean up benign vcpu->cpu data races when kicking vCPUs KVM: Guard cpusmask NULL check with CONFIG_CPUMASK_OFFSTACK Vitaly Kuznetsov (2): KVM: Optimize kvm_make_vcpus_request_mask() a bit KVM: x86: Fix stack-out-of-bounds memory access from ioapic_write_indirect() arch/x86/kvm/ioapic.c | 10 +++--- virt/kvm/kvm_main.c | 83 ++++++++++++++++++++++++++++++++----------- 2 files changed, 68 insertions(+), 25 deletions(-) -- 2.31.1