Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1258672pxb; Fri, 13 Nov 2020 08:08:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+giO7ELy3cQugjiuTOJPuwUCD6I9gZRFF1a8Bm1+46ux/U7NgtYQVvUGieWaFQRlXzPH1 X-Received: by 2002:aa7:d48d:: with SMTP id b13mr3101825edr.264.1605283707866; Fri, 13 Nov 2020 08:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605283707; cv=none; d=google.com; s=arc-20160816; b=nneB6wDBs4pEohtPWM9HgxevHIusyhRAbZz2ty5OxyfAkn0HbSYH9tgyAfqmH/V+l0 H4Ypmm7UeztIe/wnuz4QWkjfK2vsdrjvikQ7UVR64pjmiuJlUEPCj6YemOQjThlpBuDD KGGjT8y40PRcLoQU6qCjUzgXZhUBu+dxgh9Z3Z3mjxuS6htGW1BlzDB1SA38XOs1RSuC frUQoREvetcxk86qsER8k97D7KsuqM2ZBFR7Msr6BX8RyxSsu2J/RKB39sHGCjXMQUEr wK/aVBTcmxIPO+p2mz214JLztMiAqob9zsPQnItQwLaliedR1Ah2D2RO5IcFYpPfPmSL rlCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=m4ql9FNmRg1ulh7tLlHhtumC28zCqSX+nR7tpMMBE7A=; b=hQwj0T1vknhWnAn/K0sHEPzxyQLM4zsAFzCKbnSCwrmCUuEyP6pOHCumBm5vhIRwPG IqaSHFD8sPI/n323jVDySd31FHqkshHhUXVcRsoOgT5PCLjKYZFxC/b0GTwZEob8tZQb hH5F6/nrhwpbVwZCX7Rigaa/p9SVCYQz1eft1MzXVoD7ek5LYFtzhQ4iZamFVsubz8j2 /04u/dyih/CkQDmldutZ9UIEJKtHurx7YF8+kD2VhTc66Z5RKXs/rUcYxGD0QvV50KlX PzJcMGNROJbEl3HAKLJY4AlRxkdFgDIoBrmRfihbG+n21mQvr59LShco54fnAjnNm9Xu ld3Q== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb21si6211807edb.267.2020.11.13.08.07.58; Fri, 13 Nov 2020 08:08:27 -0800 (PST) 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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726746AbgKMQFH (ORCPT + 99 others); Fri, 13 Nov 2020 11:05:07 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42354 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726662AbgKMQFG (ORCPT ); Fri, 13 Nov 2020 11:05:06 -0500 Received: by mail-wr1-f67.google.com with SMTP id l1so10448886wrb.9; Fri, 13 Nov 2020 08:05:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=m4ql9FNmRg1ulh7tLlHhtumC28zCqSX+nR7tpMMBE7A=; b=HOWqLfBSOkB+sclZF5TAevlMzECtchP+7uF+7kyBd/n56858Fqy4EyQrLCEzVB/9Bp 76oy2L/d1fww4KhQ0k1cgn4Lml854rNslS8f+9ggRpnSnFKB0lwtyX6JM9OCDR+Yf13c fJpZ9+YVlRtmtSvuyOY2XZAHoUIK+RNMbtasYlrbj8ATeIBRLkZFtXGTiNVZ+wNG811u sr8sw4sUm5RPL/6pZhpirpn5v8wkTGuYYNpv7ckTlF2Y3pnY0C1nAezNKA1IIntk3scK bm/IxkJbij+FOBwW74r4jRxkxN65rYzy2xuCRmnN34qL7c2pGO5cDpmoFujnNgdQYkeO RKLg== X-Gm-Message-State: AOAM530JWfx7bE76ItgJXjBcyGFEq5viHvWiyNyC65LisYWEw0EJcWo0 +y8zybS5F8CbR4WM9Z+Uqn4= X-Received: by 2002:adf:eb4d:: with SMTP id u13mr4191440wrn.146.1605283500131; Fri, 13 Nov 2020 08:05:00 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id o184sm10669845wmo.37.2020.11.13.08.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:04:59 -0800 (PST) Date: Fri, 13 Nov 2020 16:04:58 +0000 From: Wei Liu To: Vitaly Kuznetsov Cc: Wei Liu , Linux on Hyper-V List , virtualization@lists.linux-foundation.org, Linux Kernel List , Michael Kelley , Vineeth Pillai , Sunil Muthuswamy , Nuno Das Neves , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" Subject: Re: [PATCH v2 17/17] x86/hyperv: handle IO-APIC when running as root Message-ID: <20201113160458.fyalsxpse5bg25dd@liuwe-devbox-debian-v2> References: <20201105165814.29233-1-wei.liu@kernel.org> <20201105165814.29233-18-wei.liu@kernel.org> <87v9eawm2e.fsf@vitty.brq.redhat.com> <20201113160158.idndhuygfgenxyhm@liuwe-devbox-debian-v2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201113160158.idndhuygfgenxyhm@liuwe-devbox-debian-v2> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 13, 2020 at 04:01:58PM +0000, Wei Liu wrote: > On Thu, Nov 12, 2020 at 05:56:41PM +0100, Vitaly Kuznetsov wrote: > [...] > > > +static unsigned int hv_ioapic_startup_irq(struct irq_data *data) > > > +{ > > > + u16 status; > > > + struct IO_APIC_route_entry ire; > > > + u32 vector; > > > + struct irq_cfg *cfg; > > > + int ioapic; > > > + u8 ioapic_pin; > > > + int ioapic_id; > > > + int gsi; > > > + union entry_union eu; > > > + struct cpumask *affinity; > > > + int cpu, vcpu; > > > + struct hv_interrupt_entry entry; > > > + struct mp_chip_data *mp_data = data->chip_data; > > > + > > > + gsi = data->irq; > > > + cfg = irqd_cfg(data); > > > + affinity = irq_data_get_effective_affinity_mask(data); > > > + cpu = cpumask_first_and(affinity, cpu_online_mask); > > > + vcpu = hv_cpu_number_to_vp_number(cpu); > > > + > > > + vector = cfg->vector; > > > + > > > + ioapic = mp_find_ioapic(gsi); > > > + ioapic_pin = mp_find_ioapic_pin(ioapic, gsi); > > > + ioapic_id = mpc_ioapic_id(ioapic); > > > + ire = ioapic_read_entry(ioapic, ioapic_pin); > > > + > > > + /* > > > + * Always try unmapping. We do not have visibility into which whether > > > + * an IO-APIC has been mapped or not. We can't use chip_data because it > > > + * already points to mp_data. > > > + * > > > + * We don't use retarget interrupt hypercalls here because Hyper-V > > > + * doens't allow root to change the vector or specify VPs outside of > > > + * the set that is initially used during mapping. > > > + */ > > > + status = hv_unmap_ioapic_interrupt(gsi); > > > + > > > + if (!(status == HV_STATUS_SUCCESS || status == HV_STATUS_INVALID_PARAMETER)) { > > > + pr_debug("%s: unexpected unmap status %d\n", __func__, status); > > > + return -1; > > > > Nit: the function returns 'unsigned int' but I see other 'irq_startup' > > routines return negative values too, however, they tend to returd > > '-ESOMETHING' so maybe -EFAULT here? > > > > The return type should've been int instead. That's what the function > signature in struct irq_chip looks like. Actually it is unsigned int. Oh well. Wei.