lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 07 May 2024 15:48:05 +0800
From: Xi Ruoyao <xry111@...111.site>
To: lijun <lijun01@...inos.cn>, chenhuacai@...nel.org, kernel@...0n.name, 
	lvjianmin@...ngson.cn, dongbiao@...ngson.cn, zhangbaoqi@...ngson.cn
Cc: loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] LoongArch: Update the flush cache policy

On Tue, 2024-05-07 at 14:38 +0800, lijun wrote:
> I guess, final the value of addr is not important, just all of addr must 
> read once is very important,
> 
> so use two 'for()' and 'volatile' to flush all of addr  's cache, 
> exactly as the name of the function is
> 
> "flush_cache_last_level".

AFAIK do a read does not mean flushing the cache.  The cacop instruction
is intended to do the cache flushing.

So why the cacop instruction in flush_cache_leaf is not enough to flush
it?  Is there something wrong in flush_cache_leaf?  It currently reads:

static void flush_cache_leaf(unsigned int leaf)
{
    int i, j, nr_nodes;
    uint64_t addr = CSR_DMW0_BASE;
    struct cache_desc *cdesc = current_cpu_data.cache_leaves + leaf;

    nr_nodes = cache_private(cdesc) ? 1 : loongson_sysconf.nr_nodes;

    do {
        for (i = 0; i < cdesc->sets; i++) {
            for (j = 0; j < cdesc->ways; j++) {
                flush_cache_line(leaf, addr);
                addr++;
            }

            addr -= cdesc->ways;
            addr += cdesc->linesz;
        }
        addr += (1ULL << NODE_ADDRSPACE_SHIFT);
    } while (--nr_nodes > 0); 
}

There is something bizarre: the flush_cache_line function uses the cacop
instruction in the Index Invalidate / Invalidate and Writeback mode, and
if I read the LoongArch manual correctly in this mode CSR_DMW0_BASE and
1ULL << NODE_ADDRSPACE_SHIFT are just ignored.

Is this something undocumented or flush_cache_leaf is just "incorrect"?

-- 
Xi Ruoyao <xry111@...111.site>
School of Aerospace Science and Technology, Xidian University

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ