Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6498316ybh; Thu, 8 Aug 2019 01:00:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7NZFkvRH+A4spK2i+HhmfqL4FzM4nbaTVoyggSJFWFk6SphTCYiMt8ugW5B8L/7IdxqeW X-Received: by 2002:a62:640c:: with SMTP id y12mr13872636pfb.166.1565251259884; Thu, 08 Aug 2019 01:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565251259; cv=none; d=google.com; s=arc-20160816; b=0xZFShO8Non184vBrGMov509QCo6mN4McJxL3sZxV/nBhYfQ+Dwg8r0ZBS3Lw2phlU CI419zxIkh98q7UAiEN/a36/K8tGCzpmVg9HgUp7PrU2otamYrR6R9iJ5fkyZLjroPQC Mc3MrM53kcoMabNPiy7fuGWAA5IgRJlsU6UZ9lAfwXiws38P6uVHCP8YxJ667i2TMNeB Zdj1DaXG4PXXWFb4K0ZD9ywOZfVLvvjgE8MVqUWDNhgRM0DBc95v10MPR8ZP5GAYZNJc ENqpasSF7B7cp8ucPUXMLPOUlb0pn6cFhz8ekigfEP6P7Fx+ZnvBpIHR78Th5QmVcJ04 8+2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=Mj0NlYSUurL6xj8Jw3i+0MeK0CDZOCR1M77+F9BwytE=; b=WDzKLLJ7RCsGvmdinkVxSQ7m4cOBZ0b1U6dzc3LOuUJoyAZKRXJyUEbONgrjwIKOId T6638OVAIT2H7Vxkyx0/UnZg9pa6dj4M+vaJFsKyWlcdcsCaNh4i72IfR/3IZpRN+NTC +xHvcJFLjOqXNqyeVC7IlUKzL+jzSXNhGjrYHQTwUAbxZH9QM4MRroTnRKuG96WimvGP pB5pcLSl6PLwdf3EyltsXWx3yXsTid/9HaOPGIXG4qIO6LxKg6ZFBZNPoh+bYACyZ8pL 0Z9N7KGG5BrjtwaNNsOF170R+suaadZdHLdmvhLBJEVBV8Z4Lm5blBk5J/6LXxNBjsYB gZvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ZmFoFiuF; 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 i127si49943762pfc.177.2019.08.08.01.00.43; Thu, 08 Aug 2019 01:00:59 -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; dkim=pass header.i=@sifive.com header.s=google header.b=ZmFoFiuF; 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 S1731789AbfHHIAC (ORCPT + 99 others); Thu, 8 Aug 2019 04:00:02 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34135 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731548AbfHHIAC (ORCPT ); Thu, 8 Aug 2019 04:00:02 -0400 Received: by mail-pf1-f195.google.com with SMTP id b13so43641123pfo.1 for ; Thu, 08 Aug 2019 01:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id; bh=Mj0NlYSUurL6xj8Jw3i+0MeK0CDZOCR1M77+F9BwytE=; b=ZmFoFiuFuEhRJV21WykRlWUovgwSUqqTFjQJtAVC3DZs9ENOnjbPjAb/yiWK8PreJ8 c2mnbTcpUBkOX5yrPYDjGZT1Atk+5/zgQaUFCvL7xOTjHJaUQ9YcfwQOu3g3oSiZW+AM 9m5gSVyyGv6FgsMCoj8O0sMg0tUx/sRahn1yQpLFeilUzMGBBsP3NwtpnfxYKO2UEj4v H0MkwgSVoHQh77whMNTwaSX+OVH8ZSwQ0rCGvmMl2mIMVJTdv0caL7Dq6hTVDTkSf9Wa Rkq+pjCFxwGS8VABoAYUgIea2CilG2bMTvG9f0NFLJlA0sybY7IR89paSM0ySD0Qp4Yr vT4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Mj0NlYSUurL6xj8Jw3i+0MeK0CDZOCR1M77+F9BwytE=; b=CcfF1YwPktD02ylf6gTKbqE/KLPNNtN7zfezMDjimBRXwlADpA752HL6tSRT3EZwU0 0SdsClXtw40KlTRTY6VH1/OY6NoCutIw2MvfJ4nqnGhXIyB6PxdBmqFQJBnaM2Kv/uPD oHjvH9MuYgvZmfmOYfZp8/oAdc75Q7e2hyjStL/G7gur2Fpvme7SA6qdzRUxxI5OfGIk LVQrRX3i9I2Iv9cYwGdU6+UEZ5Bf2HjOHmU3WZKhICnCFctmkUdtV1R+QTGZz/teDsJG T6eaE1WODHwpVEXngG0vAnwVagigQcscxeWwO3V03Oy/mJUP0g7W2zgu4+T7vqXAeB3X LQ+w== X-Gm-Message-State: APjAAAVqH6MxZIRZ+bH2GuG/NWL7VJz/J6+2QGw8MhlW5kyJhWUXkl8F YZasoUrqBXPpbMVU2QCDJoRc5uhoozs= X-Received: by 2002:a17:90b:8e:: with SMTP id bb14mr2717479pjb.19.1565251201455; Thu, 08 Aug 2019 01:00:01 -0700 (PDT) Received: from localhost.localdomain (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id t8sm107697374pfq.31.2019.08.08.00.59.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Aug 2019 01:00:01 -0700 (PDT) From: Vincent Chen To: paul.walmsley@sifive.com, palmer@sifive.com, aou@eecs.berkeley.edu Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Vincent Chen Subject: [PATCH 0/2] riscv: Correct the initialized flow of FP and __fstate_clean() Date: Thu, 8 Aug 2019 15:58:39 +0800 Message-Id: <1565251121-28490-1-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following two reasons cause FP registers are sometimes not initialized before starting the user program. 1. Currently, the FP context is initialized in flush_thread() function and we expect these initial values to be restored to FP register when doing FP context switch. However, the FP context switch only occurs in switch_to function. Hence, if this process does not be scheduled out and scheduled in before entering the user space, the FP registers have no chance to initialize. 2. In flush_thread(), the state of reg->sstatus.FS inherits from the parent. Hence, the state of reg->sstatus.FS may be dirty. If this process is scheduled out during flush_thread() and initializing the FP register, the fstate_save() in switch_to will corrupt the FP context which has been initialized until flush_thread(). In addition, the __fstate_clean() function cannot correctly set the state of sstatus.FS to SR_FS_CLEAN. These problems will be solved in this patch set. Vincent Chen (2): riscv: Correct the initialized flow of FP register riscv: Make __fstate_clean() can work correctly. arch/riscv/include/asm/switch_to.h | 8 +++++++- arch/riscv/kernel/process.c | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) -- 2.7.4