Received: by 10.213.65.68 with SMTP id h4csp1306092imn; Sun, 18 Mar 2018 23:50:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELvK4ZzhgSZzKL0Tx9iKbcY16b43YIMDxBCfuE+obikyyvJicWGilvWCKOtYCu8SL3OXG7Y7 X-Received: by 2002:a17:902:8b82:: with SMTP id ay2-v6mr11093664plb.12.1521442253297; Sun, 18 Mar 2018 23:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521442253; cv=none; d=google.com; s=arc-20160816; b=1IeyiXAZ6LfX5Rq59EJN7qB2a/hQ615aouXzxAtS7frfHytyqVPI/2QOQ8EVclbvjU W9PRraWZpghbzC95/j4Gbc6Ngi2NRuDgEtPnO+PASCXwps/usNYlNfz7ihCEeUaAWgPN +dkGeyA69kvDa7tOyxlCMV44ypLYZ+Q4URsBBfjjOSzkwN1hjeqp7VauNTotch+NpuZp y6MJvzLXJB9wSKH/HoLxLWdiSEDtNGAFUQ/roeSYfMWrb0S73w5kLVCcO661HoPVgZM8 2Pl/VTZynf7dOz73QyXjdS0mQT4zLOVg52ZgAcls8sMThNCF1tTFmiSMzK9gagEm9QVf DJ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Cp67f8NXPXQJ4GaghQbfOrXcpV+p9DcM4V9Dya6XdnE=; b=Lr3ytE6f0NpYMj1T0nI/non3uTa5Ek5p+u3NimBS10NAJiSyPTohxukfGtr3NOxHdr GB3RTUIX+qVSMOrY1TsTwJejf5qqlUMjaAu7ftble6YSBnQw6CyjNb5OHRAu+IZBATQ3 sSRJZfSIFtRQkWULQRbx6OQsgEKP002YZQmXd9YGD8EuYKAuGiDLoWbg6xUuLwxm69dL muUZG270RuzB6IHLXWo6Bjt2WpqBC1ahwkc0BJQM1qEXTH9QFDtusgfOxUuh2RzKFHMW ONGIvfHeiBfCFaQdCo5mHZq+O/7iG97h+BX7Kt/IWtvFC/HhcFEhzxIHvnxLyjNsEByz EePg== 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 t9si9286232pgn.157.2018.03.18.23.50.38; Sun, 18 Mar 2018 23:50:53 -0700 (PDT) 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 S932281AbeCSGtA (ORCPT + 99 others); Mon, 19 Mar 2018 02:49:00 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:40081 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932239AbeCSGs7 (ORCPT ); Mon, 19 Mar 2018 02:48:59 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.0247243|-1;CH=blue;FP=0|0|0|0|0|-1|-1|-1;HT=e01l01425;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=11;RT=11;SR=0;TI=SMTPD_---.BMZd6v0_1521442064; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:223.93.147.148) by smtp.aliyun-inc.com(10.147.42.253); Mon, 19 Mar 2018 14:47:44 +0800 Date: Mon, 19 Mar 2018 14:47:44 +0800 From: Guo Ren To: Mark Rutland Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, daniel.lezcano@linaro.org, jason@lakedaemon.net, arnd@arndb.de, c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, thomas.petazzoni@bootlin.com, wbx@uclibc-ng.org Subject: Re: [PATCH 02/19] csky: Exception handling and syscall Message-ID: <20180319064744.GA10134@guoren-Inspiron-7460> References: <20180319014755.s2n65f3hzzemc7do@salmiak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180319014755.s2n65f3hzzemc7do@salmiak> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, > Here you open code an MFCR instruction. > > I guess MFCR stands for something like move-from-control-register, and MTCR > stands for move-to-control-register? > > I see that later on you have helpers for specific registers, e.g. mfcr_cpuidrr(). > > You might want to follow the example of arm64's read_sysreg() and > write_sysreg(), and have general purpose helpers for thos instructions, e.g. > > #define mfcr(reg) \ > ({ \ > unsigned long __mfcr_val; \ > asm volatile("mfcr %0, " #reg "\n" : "=r" (__mfr_val)); \ > __mfcr_val; \ > }) > > ... which avoids needing helpers for each register, as you can do: > > ss1_val = mfcr(ss1); > cpuidrr_val = mfcr(cpuidrr); > OK, good idea. > > + if (memblock_start_of_DRAM() != (PHYS_OFFSET + CONFIG_RAM_BASE)) { > > + pr_err("C-SKY: dts-DRAM doesn't fit .config: %x-%x.\n", > > + memblock_start_of_DRAM(), > > + PHYS_OFFSET + CONFIG_RAM_BASE); > > + return; > > + } > > If this is a problem, is it safe to continue at all? > > Why does the base address of RAM matter? > We use mips-like direct-mapping tech, and it need 512MB boundary alignment. And few users need non-512MB boundary phy-addr start, so we give the CONFIG_RAM_BASE for determine the offset to PHYS_OFFSET. > > + > > + mtcr_msa0(PHYS_OFFSET | 0xe); > > + mtcr_msa1(PHYS_OFFSET | 0x6); > > As with MFCR, you could use a generic helper here, e.g. > > #define mtcr(val, reg) \ > do { \ > asm volatile("mtcr %0, " #reg "\n" : "=r" ((unsigned long)val)); \ > } while (0); > > mtcr(PHYS_OFFSET | 0xe, msa0) > mtcr(PHYS_OFFSET | 0x6, msa1) > OK > > + seq_printf(m, "C-SKY CPU : %s\n", CSKYCPU_DEF_NAME); > > + seq_printf(m, "revision : 0x%08x\n", mfcr_cpuidrr()); > > + seq_printf(m, "ccr reg : 0x%08x\n", mfcr_ccr()); > > + seq_printf(m, "ccr2 reg : 0x%08x\n", mfcr_ccr2()); > > + seq_printf(m, "hint reg : 0x%08x\n", mfcr_hint()); > > + seq_printf(m, "msa0 reg : 0x%08x\n", mfcr_msa0()); > > + seq_printf(m, "msa1 reg : 0x%08x\n", mfcr_msa1()); > > Do these need to be exposed to userspace? > Yes, I'll add more explain info. > Does this arch support SMP? I see you don't log information per-cpu. This patch-set doesn't support SMP. > > > diff --git a/arch/csky/kernel/entry.S b/arch/csky/kernel/entry.S > > > +#define THREADSIZE_MASK_BIT 13 > > You might want to define this as THREAD_SHIFT, and define THREAD_SIZE in terms > of it, so that they're guaranteed to be in sync > > e.g. in your have: > > #define THREAD_SHIFT 13 > #define THREAD_SIZE (1 << THREAD_SHIFT) OK > If you have a spare register that you can point at the current task (or you > have preemption-safe percpu ops), I'd recommend moving the thread_info off of > the stack, and implementing THREAD_INFO_IN_TASK_STRUCT. > Em... I'll think about it. > For consistency, and in case you change your stack size in future, this should > be THREADSIZE_MASK_BIT. > OK > > + if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END)) > > + goto vmalloc_fault; > > You might want to check if this was a user mode fault here, so that users can't trigger vmalloc faults. Is it necessary to check user mode? If a user-process touch a kernel-addr, it will cause a supervisor exception. Best Regards Guo Ren