Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp800798imj; Sat, 9 Feb 2019 08:12:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IZr2bOeT5RoIVdZUMxCLPKiirDWMBsVjuhk4LUqXWaMPszRH7o6zO0fZWVXGTbkYlQGZjWB X-Received: by 2002:a17:902:6508:: with SMTP id b8mr16655930plk.17.1549728753042; Sat, 09 Feb 2019 08:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549728753; cv=none; d=google.com; s=arc-20160816; b=HJ4XofskxOoMKj4VLUp/tUpZUCQ8yl0MI7B3oFtTeXAnnfz1vSYy0SWFq+mzdpY5Od ceItkM+ced34cRMGkbr0Czb9hKYtqPbStoNSNTFz5v6AFctH5uqNCo7N9VC8EZcW2cey 90DJ8nYUxngRxgx64O5HbqGmB8isxkKrrMHbQpMmr3iGx1VRFBVo59N3x6Ofyf9fzVyx YR0TYkOyPTJiSeBlMrzpfIEHuWm8itWa9wNS8e7il5PhulcvAUv+zqYvlCQZtua6R4gA d9N/6zBCQIP7xRsdy4GNhzQAKw5p6xPa96v+eAFCWQpfD7SwLaiNwOMW5SaC3LSusv6Y 3S/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:user-agent :references:in-reply-to:subject:cc:to:from:message-id:date; bh=xtYUfaPOz4xxopOyoBk6dxCiN5hhV0BIqG+4T90/EjQ=; b=kusFTsG3hVVdkxk9PmAhXLimtEV5WEPpw8n/o+m3HbeFGPWakaWAGTcSZSu4Y8Mjdw UHv7o5vTqi1dbiJs/C0rZzFjzF20m4bUhYJrfEJsT7QZSlYZFiPVyIw4CV7R1j4aNmaF jiy1RACkGG9iE3T7uzDiG8MzOTckothrczW7rH2ZUJgUCA/MMRzt3mfMzprQGZLQ2LNI h7LvVEoo/+qs3UfNwBABOrGQjwgcXWxZVnlf2o3k6W27J4s5a1heNLZJsZJfNAooRlaJ h0fNTtXzea3xDNafbEsI+MM/zikCQwjW51c/DqvDqj9OGQ8X6PG9rv8HIn5UI9FBO+ro +LYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si5923162pfm.149.2019.02.09.08.12.12; Sat, 09 Feb 2019 08:12:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727012AbfBIQLy (ORCPT + 99 others); Sat, 9 Feb 2019 11:11:54 -0500 Received: from foss.arm.com ([217.140.101.70]:33770 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbfBIQLy (ORCPT ); Sat, 9 Feb 2019 11:11:54 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B0663A78; Sat, 9 Feb 2019 08:11:53 -0800 (PST) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 129FE3F589; Sat, 9 Feb 2019 08:11:43 -0800 (PST) Date: Sat, 09 Feb 2019 16:11:42 +0000 Message-ID: <86bm3lt001.wl-marc.zyngier@arm.com> From: Marc Zyngier To: David Abdurachmanov Cc: Atish Patra , Christoph Hellwig , Damien Le Moal , Albert Ou , Jason Cooper , Alan Kao , Dmitriy Cherkasov , Anup Patel , Daniel Lezcano , Patrick =?UTF-8?B?U3TDpGhsaW4=?= , "linux-kernel@vger.kernel.org" , Palmer Dabbelt , Paul Walmsley , Andreas Schwab , "linux-riscv@lists.infradead.org" , Thomas Gleixner , Zong Li Subject: Re: [v3 PATCH 8/8] RISC-V: Assign hwcap only according to boot cpu. In-Reply-To: References: <1549590681-24125-1-git-send-email-atish.patra@wdc.com> <1549590681-24125-9-git-send-email-atish.patra@wdc.com> <20190208091133.GD16932@infradead.org> <8f5fd0c8-0320-00b1-4ddf-b1225be352c8@wdc.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 09 Feb 2019 04:26:07 +0000, David Abdurachmanov wrote: > > On Sat, Feb 9, 2019 at 12:03 AM Atish Patra wrote: > > > > On 2/8/19 1:11 AM, Christoph Hellwig wrote: > > >> + * We don't support running Linux on hertergenous ISA systems. > > >> + * But first "okay" processor might not be the boot cpu. > > >> + * Check the ISA of boot cpu. > > > > > > Please use up your available 80 characters per line in comments. > > > > > I will fix it. > > > > >> + /* > > >> + * All "okay" hart should have same isa. We don't know how to > > >> + * handle if they don't. Throw a warning for now. > > >> + */ > > >> + if (elf_hwcap && temp_hwcap != elf_hwcap) > > >> + pr_warn("isa mismatch: 0x%lx != 0x%lx\n", > > >> + elf_hwcap, temp_hwcap); > > >> + > > >> + if (hartid == boot_cpu_hartid) > > >> + boot_hwcap = temp_hwcap; > > >> + elf_hwcap = temp_hwcap; > > > > > > So we always set elf_hwcap to the capabilities of the previous cpu. > > > > > >> + temp_hwcap = 0; > > > > > > I think tmp_hwcap should be declared and initialized inside the outer loop > > > instead having to manually reset it like this. > > > > > >> + } > > >> > > >> + elf_hwcap = boot_hwcap; > > > > > > And then reset it here to the boot cpu. > > > > > > Shoudn't we only report the features supported by all cores? Otherwise > > > we'll still have problems if the boot cpu supports a feature, but not > > > others. > > > > > > > Hmm. The other side of the argument is boot cpu does have a feature that > > is not supported by other hart that didn't even boot. > > The user space may execute something based on boot cpu capability but > > that won't be enabled. > > > > At least, in this way we know that we are compatible completely with > > boot cpu capabilities. Thoughts ? > > There is one example on the market, e.g., Samsung Exynos 9810. > > Mongoose 3 (big cores) only support ARMv8.0, while Cortex-A55 > (little ones) support ARMv8.2 (and that brings atomics support). > I think, it's the only ARM SOC that supports different ISA extensions > between cores on the same package. > > Kernel scheduler doesn't know that big cores are missing atomics > support or that applications needs it and moves the thread > resulting in illegal instruction. Not quite. The scheduler doesn't have to know (thankfully). The problem is that the Samsung folks tampered with the detection logic in the kernel, and ended up advertising the LSE atomics to userspace (despite only being available on half the cores). If you run a mainline kernel on this things, it will just work, as the LSE atomics are not advertised to userspace at all. > > E.g., see Golang issue: https://github.com/golang/go/issues/28431 > > I also recall Jon Masters (Computer Architect at Red Hat) advocating > against having cores with mismatched capabilities on the server > market. Well, nobody recommends that, server or not. That being said, it is possible to handle it, and the arm64 kernel has been dealing with such thing from day 1. We can have CPUs with different PMUs, implemented page sizes, VA and PA spaces... What it takes is some work in the kernel to sanitize it, and be careful in what you expose to userspace. The thing to realise is that people will build stupid systems, no matter how loud you shout. You can either pretend they don't exist, or try to deal with them. Thanks, M. -- Jazz is not dead, it just smell funny.